7. AngularJS中的指令 ng-switch

2017-10-09  本文已影响0人  小草莓蹦蹦跳
<body ng-app=app ng-controller=wmxController>

<ul>
    <li ng-repeat="item in array" ng-switch="item">
        {{item}}
    </li>
</ul>

<hr>

<ul>
    <!--ng-switch必须和ng-switch-when搭配着使用-->
    <li ng-repeat="item in array" ng-switch="item">
        <!--当item和css相等的时候就可以显示-->
        <span ng-switch-when="jq"> {{item}} </span>
    </li>
</ul>

<script src='angular.js'></script>

<script>

    var app = angular.module('app',[]);

    app.controller('wmxController',['$scope',function ($scope) {
        $scope.array = ['html','css','js','jq'];
    }])

</script>
</body>
上一篇下一篇

猜你喜欢

热点阅读