I am working on angular js project in which we are using ng-repeat to display list of strings in cell template created using custom directives.
It working fine for list of numbers. But it does not works for list of strings.
You can try by changing number to string on plunker
var viewFn = "<div>View: <span ng-repeat='x in [1,2,3]'>{{x}}</span></div>";
...
var editFn = "<div>Edit: <span ng-repeat='x in ["Hi","Hello"]'>{{x}}</span></div>";
How can I get list of string using cell template?
The problem is the string character that you are using.
You can avoid it using template literals (backtick char).
Change your template using it like:
var editFn = `<div>Edit: <span ng-repeat="x in ['Hi','Hello']">{{x}}</span></div>`;
Because editFn
is a string, the quotes in your ng-repeat array need to be escaped.
Try: var editFn = "<div>Edit: <span ng-repeat='x in [\\"Hi\\",\\"Hello\\",\\"Hey\\"]'>{{x}}</span></div>";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.