javascript - Define ng-model by name -
i have complex model, example:
model = { "data_level1": { "data_level2": { "data_level3": { "data_level4": "myvalue"...
how can avoid writing:
<input type="text" ng-model="model.data_level1.data_level2.data_level3.data_level4" />
and write instead like:
<input type="text" ng-model="data_level4" />
thanks.
do in controller:
$scope.submodel = $scope.model.data_level1.data_level2.data_level3;
and then:
<input type="text" ng-model="submodel.data_level4" />
note: can't set submodel
data_level4
because string, setting data_level3
have submodel
referencing same object within original model
.
edit: added pnlkr done @ryanyuyu
Comments
Post a Comment