I am trying to build an object like:
{"age":"21","name":"foo", "address":["address1", "address2"]}
For address I am using a custom directive, I don't know how to attach this to scope (person.address). If I give ng-model="person.address" in directive, it is taking same address for both the input texts. I have to isolate scope, but don't know where to put it.
Fiddle: http://codepen.io/goutham2027/pen/EagPZG
HTML
<div ng-controller="testCtrl">
<form>
Name: <input type="text", ng-model="person.name"> <br/>
Age: <input type="text", ng-model="person.age"> <br/>
Address-1 <address> </address>
Alternate-Address <address> </address>
</form>
{{person}}
</div>
JS
app.directive('address', function() {
return {
restrict: 'E',
template: '<input type="text">'
}
})
Edit: I found out how to do it. Fiddle: http://codepen.io/goutham2027/pen/LEjaXP