这个指令 和 ng-switch-when 以及 on="name"一起使用
在name值发生变化时渲染不同的指令到视图中
例子:
代码语言:javascript复制<!DOCTYPE html>
<html ng-app="myApp">
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<div ng-controller="SomeController" ng-switch on="person.name">
<input type="text" ng-model="person.name" />
<p ng-switch-default>And the winner is</p>
<h1 ng-switch-when="Erik">{{ person.name }}</h1>
</div>
<script type="text/javascript" src="../js/angular.min.js"></script>
<script>
var app = angular.module('myApp', []);
app.controller('SomeController', function($scope) {
$scope.person = {};
});
</script>
</body>
</html>
ng-switch-default 输出默认值