In controller I\'ve a list like this:
scope.data = [ { user: { address: { city: \'Boston\'} } } ];
And a property, where I\'ve the name to acce
You can do it like this because of ng-repeat
:
<input ng-model="item.user.address.city" />
So you do not need to declare this:
$scope.propertyName = 'address.city';
Demo
You can create a directive with compile, to set ng-model indirectly:
compile: function(el, attrs) {
return function(scope, el) {
el.attr('ng-model', attrs.ngModelItem + '.' + scope[attrs.ngModelRef]);
$compile(el)(scope);
};
}
please look my sample on jsbin:
http://jsbin.com/xizucu/edit?html,js,output