<!--标准用法--> <div ng-switch on="showSecret"> <div ng-switch-when="true">Secrect</div> <div ng-switch-default>Won't show you my Secrects!</div> </div> <!--灵巧用法--> <li ng-repeat="crumb in crumbs.getAll()"> <span class="divider">/</span> <ng-switch on="$last"> <span ng-switch-when="true">{{crumb.name}}</span> <span ng-switch-default> <a href="{{crumb.path}}">{{crumb.name}}</a> </span> </ng-switch> </li> <!--灵巧用法II--> <tbody ng-repeat="user in users" ng-click="selectUser(user)" ng-switch on="isSelected(user)"> <tr> <td>{{user.name}}</td> <td>{{user.email}}</td> </tr> <tr ng-switch-when="true"> <td colspan="2">{{user.desc}}</td> </tr> </tbody> <!--ng-switch-when和-default必须作为属性,不能作为元素标签用--> <!--例如下面这种写法是不行的!(已验证)--> <ng-switch on="$last"> <ng-switch-when="true">{{crumb.name}}</ng-switch-when> <ng-switch-default> <a href="{{crumb.path}}">{{crumb.name}}</a> </ng-switch-default> </ng-switch>