Reputation: 2496
I get an array of string like this ["create-user", "edit-user", "read-user", "delete-user"]
in console, now i want to pass it to view .
My code :
<tr ng-repeat="perm in permsAll">
<td>
{{perm == "create-user" : X ? ' '}}
</td>
<td>
{{perm == "create-edit" : X ? ' '}}
</td>
....
</tr>
So i get all strings but not that what i want :( , i want if user have create-user for example make a X in td example userX = createUser: X
if not have create-use it will be empty .
How to do it ? , i guess i must to use directive. and thanks ?
Upvotes: 0
Views: 73
Reputation: 1568
You can do it in different ways.
You can try to use a ng-switch or a ng-if or even a ng-show.
For example:
<td ng-if="perm.contain === 'create-user'>X </td>
If you want to use the code you have you have to change for something like:
<td>
{{perm.contain === 'create-user' ? 'X' : ' '}}
</td>
edited: added literal string
Upvotes: 3
Reputation: 1296
You are trying to use the wrong operator, try this:
{{perm.contain == "create-user" : X ? ' '}}
But your best bet would be like sexta said:
<td ng-show="perm.contain == 'create-user' ">X</td>
Hope it helps =)
Upvotes: 2