Display Enum text in Angularjs

4,328 views
Skip to first unread message

Arun Kumar

unread,
Dec 30, 2013, 3:43:44 PM12/30/13
to ang...@googlegroups.com
Hi ,
 
I have an enum {available=0 and Open=1}.When i display in ng-reapeat..it is hsowing 1/0.I want it to be displayed as Available intead of 0 and Open instead on 1 .Please help me.
 
Thanks,
Arun

satish venkatakrishnan

unread,
Dec 30, 2013, 10:10:43 PM12/30/13
to ang...@googlegroups.com

You are looking for filters.. But you need write a custom one

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.

Aleck Landgraf

unread,
Dec 31, 2013, 12:22:14 AM12/31/13
to ang...@googlegroups.com
See: http://stackoverflow.com/questions/11985863/how-to-use-ng-repeat-for-dictionaries-in-angularjs

You can iterate over objects or dictionaries like so:
<li ng-repeat="(name, age) in items">{{name}}: {{age}}</li>
where items = {"a name": 25, "another name": 35};

so in your case:
<li ng-repeat="(key, value) in enum"> {{key}} </li>
Reply all
Reply to author
Forward
0 new messages