angularjs - Add a calculated class to an HTML element in angular -


i render bunch of user icons on page. want give them class based on id.

example user object

{ id: 1234, name: "foo" } 

html element

<div ng-repeat="user in userlist" class="something-{{ user.id % 10 + 1 }}"> </div> 

so classes "something-1", "something-2", ... based on users id.

the above code doesn't work. no class shows on element. right way this?

please give try ng-init. in case html be

<div ng-repeat="user in userlist" ng-init="myid = (user.id % 10) + 1;" class="something-{{ myid }}"> </div> 

Comments

Popular posts from this blog

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -