Slava, I’m not too sure if this is a good idea to begin with. But anyhow,
You need to make your model getterSetter aware by adding this property to your input ng-model-options="{ getterSetter: true }
.
Then you need a function in your controller that builds a getterSetter out of a sting.
<input type="text" ng-model="propertify('entity.' + path)" ng-model-options="{ getterSetter: true }">
That’s how the resulting template would look.
Luckily angular has an $parse service that makes this a lot easier. so something like this would need to be in your controller, or even better in a injected service.
$scope.propertify = function (string) {
var p = $parse(string);
var s = p.assign;
return function(newVal) {
if (newVal) {
s($scope,newVal);
}
return p($scope);
} ;
};
That will return a getter-setter function that handles this for you.
see it in action in this plunk