ng-switch 指令

<!--标准用法-->
<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>

 

转载于:https://www.cnblogs.com/Denny_Yang/p/4533297.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值