You need to use the bracket notation to access the property and not the dot notation. This is because ngModel
binds the attirbute to the scope using =
, so the value is not interpolated.
<input type="text" ng-model="properties[type].value">
Pergunta
In angularjs I have this code:
<input type="text" ng-model="properties.foreground.value">
I want it to be like:
<input type="text" ng-model="properties.{{type}}.value">
I changed a part of the model input to be a string. It does not work. Can it be done some other way?
Solução
You need to use the bracket notation to access the property and not the dot notation. This is because ngModel
binds the attirbute to the scope using =
, so the value is not interpolated.
<input type="text" ng-model="properties[type].value">