Is there a way for this ng-switch to obtain?

53 views Asked by At

I'm basically new to angular and here I am asking for help. I've been looking around google for an answer but I can't.

So here goes my code.

<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>

The 'cancel' link wont show up on the nested ng-switch here with my

ng-switch-when="account.account"

but will show up when I replace the 'account.account' into literal value

ng-switch-when="A0011"

EDIT

I forgot adding some values

My table is like this:

Current Account Value is 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

Any hint? Any help is much appreciated.

Thank you.

2

There are 2 answers

0
Kalhan.Toress On BEST ANSWER

you cannot use expressions with ngSwitch reference

so account.account is treat as just a string.

use ng-if instead

<div ng-if="account.account">
    <a href="#">Cancel</a>
</div>
0
Dinesh ML On

ng-switch-when requires boolean value