I am trying to get an array into a template to use its values. My problem is that the attribute turns into a string once inside my template, so it is no longer available as {{var [0]}} and will instead return the first character of the "string", usually "["
Here is a simplified data setup:
"varForward": ["100", "1"], "varBack": ["1", "100"]
Here is the simplified part of the HTML file that interacts with this data:
<my-customer-vars value="{{varForward}}"> </address-numbers> <my-customer-vars value="{{varBack}}"> </address-numbers>
and finally, here is the part that is SUPPOSED for replacing the user tag with my own things:
directive('myCustomerVars', function($compile) { return { restrict: 'E', scope: { value: "@" }, template: '<div>'+ '<p class="body-text">Some stuff goes here</p>'+ '<input type="text" name="firstinput" value="{{value[0]}}"> - '+ '<input type="text" name="secondinput" value="{{value[1]}}">'+ '</div>', replace: true } });
So now, if I try to use the value [0], I get [If I try to get the value [1], I get ", etc. Is there any help in using arrays inside the directive template?
javascript html angularjs
Organiccat Feb 04 '13 at 21:15 2013-02-04 21:15
source share