Stackoverflow Stackoverflow - 1 month ago 7
AngularJS Question

AngularJS: How to create and use an array for a value in the HTML

I have created a custom directive with fields:

ng-model
,
input-array


<mydir ng-model="myBinding" input-array="input1,input2"></mydir>


Input 1 and input 2 are both data bindings, how can I dynamically create an array of these two and pass then in the
input-array
argument?

I do not want this logic to be in a controller or the directive.

Answer

Just wrap the variables in array braces

input-array="[input1,input2]"

Beyond that there isn't nearly enough detail in question

Comments