有没有办法让这个ng-switch获得?

时间:2014-11-28 12:05:03

标签: javascript angularjs templates controller ng-switch

我基本上对角度很新,在这里我正在寻求帮助。我一直在谷歌寻找答案,但我不能。

所以这是我的代码。

<tr valign="top" ng-repeat="tech in techies.result">
    <td>{{tech.user_id}}</td>
    <td>{{tech.account}}</td>
    <td ng-switch on="tech.ctr">
        <div ng-switch-when="1">
            <div ng-switch on="tech.account">
                <div ng-switch-when="account.account">
                    <a href="#">Cancel</a>
                </div>
            </div>
        </div>

        <div ng-switch-when="0">
            <a href="#">Assign</a>
        </div> 
    </td>
</tr>

取消&#39;链接不会出现在嵌套的ng-switch这里与我的

ng-switch-when="account.account"

但是当我更换&#39; account.account&#39;进入字面值

ng-switch-when="A0011"

修改

我忘了添加一些值

我的表是这样的:

当前账户值为A00002

TID0001 |        | Assign //if account blank, appear assign
TID0002 |        | Assign //if account blank, appear assign
TID0003 | A00011 |        //no action if already assigned to another account
TID0004 | A00002 | Cancel //should appear here the cancel if the same account value

任何提示?非常感谢任何帮助。

谢谢。

2 个答案:

答案 0 :(得分:1)

您不能将表达式与ngSwitch reference

一起使用

所以account.account被视为一个字符串。

使用ng-if代替

<div ng-if="account.account">
    <a href="#">Cancel</a>
</div>

答案 1 :(得分:0)

ng-switch-when需要布尔值