angularjs - Update ng-model from controller -
hopefully pretty simple, brain isn't working @ moment...
i have form this:
<div class="control-group"> <label class="control-label" for="cn_pref_name_j04">name on card:</label> <div class="controls"> <input type="text" name="cn_pref_name_j04" id="cn_pref_name_j04" ng-model="formdata.cn_pref_name_j04" /> </div> </div>
and have basic controller this:
app.controller("closecallspoke", function($scope){ $scope.formdata = angular.copy($scope.data); }
this automatically assign entire formdata object whatever in data object.
how can assign cn_pref_name_j04?
i tried:
$scope.formdata.cn_pref_name_j04 = angular.copy($scope.data.cn_pref_name_j04);
but "$scope.formdata undefined.
please help.
try this:
$scope.formdata = { cn_pref_name_j04 : angular.copy($scope.data.cn_pref_name_j04) };
that way $scope.formdata
initialized object has cn_pref_name_j04
property you're looking for
Comments
Post a Comment