directive ngSwitch

ngSwitch指令用于根据范围表达式在模板上有条件地交换DOM结构。ngSwitch是和ngSwitchWhen or ngSwitchDefault指令一起使用的。

例子:

index.html

<html ng-app="extendApp">
<head>
    <meta charset="UTF-8">
    <title></title>
</head>
<body ng-controller="extendController">
<div>
    <div>
        <input ng-model="name" />
    </div>
    <div ng-switch="name">
        <span ng-switch-when="ms">good</span>
        <span ng-switch-when="family">health</span>
        <span ng-switch-when="future">rich</span>
    </div>
</div>
<div>
    {{aStatus}}
</div>
<script src="framework/angular.js"></script>
<script src="myJs/aaa.js"></script>
</body>
</html>

script.js

angular.module("extendApp",[])
    .controller("extendController",function ($scope) {
        $scope.name = "";
    });

 

posted @ 2017-06-16 13:49  发福大叔  阅读(413)  评论(0编辑  收藏  举报