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 = "";
    });
原文地址:https://www.cnblogs.com/ms-grf/p/7027144.html