I am having troubles linking the inputs of my form into a defined factory that I have injected into the controller that renders the form. Here is my factory:
App.factory('DeviceSelection',function() {
var states=[{selection:{}},{selection:{}},{selection:{}},{selection:{}}];
return states;
});
And here is an input of my form:
<div class="controls">
<label class="radio">
<input type="radio" name="user[role]" id="user_role_managing_editor" value="Managing editor" ng-model='states[0].selection.hours'>
Yes
</label>
<label class="radio">
<input type="radio" name="user[role]" id="user_role_area_editor" value="Area editor", ng-model='states[0].selection.hours'>
No
</label>
</div>
So, when I try to click on that Radio box, I see the following in the JS Console:
TypeError: Cannot read property 'selection' of undefined
Does that mean that I need to initialize the model before the view is rendered. If so, where?
I am trying to achieve a multi-step form, linking all the inputs in the model, until last step is reached when I am able to send the results to an API. As asked here: