Akram Akram - 1 year ago 70
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">
{{perm.contain = "create-user" : X ? ' '}}
{{perm.contain = "create-edit" : X ? ' '}}

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 Source

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

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