Hello there!
I'm trying to use non-trivial expressions inside of
ngModel directive in order to generate form elements dynamically (using
ngRepeat loop).
However, it's not working as expected.
I've created a minimal
Plunk to demonstrate the idea.
Here's the code inside of my controller:
$scope.entity = {
firstName: 'Jack',
lastName: 'Bauer',
location: {
city: 'New York'
}
};
$scope.path = 'location.city';
I've managed to display input field correctly with proper value this way:
<input type="text" ng-model="$eval('entity.' + path)">
However, I can't change the value. It's not editable. I'm getting the following error:
Error: ngModelSet is not a function
What could be the reason for this? Is there a way to solve my problem? I need to access property of the object using
property path, e.g.:
user.location.city.
I will gladly accept any suggestions, thank you!
---
Also, here's the
question on SO.