Akram Akram - 2 months ago 10
AngularJS Question

Change behavior inside ng-repeat Angularjs




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.contain = "create-user" : X ? ' '}}
</td>
<td>
{{perm.contain = "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 ?

Answer

I think your problem may be the .contain. Try this:

 {{perm === "create-user" ? 'X' : ''}}
Comments