0
在我的HTML頁面的不同領域的工作,我有5 6個不同領域的形式
<input type="text" class="form-control" ng-model="edit.TIME"placeholder="Time" maxlength="30" ng-required="true" />
<input type="text" class="form-control" ng-model="edit.NAME" placeholder="Time" maxlength="30" ng-required="true" />
<input type="text" class="form-control" ng-model="edit.Place"placeholder="Time" maxlength="30" ng-required="true" />
<input type="text" class="form-control" ng-model="edit.LASTNAME" placeholder="Time" maxlength="30" ng-required="true" />
我怎樣才能調用每個NG-模型$手錶。如果有任何改變,$ watch將顯示更改值。在我的控制器側
$scope.old.NAME="ABC";
$scope.$watch('edit', function (Value) {
if ($scope.old.NAME != $scope.edit.NAME) {
$scope.old.NAME.append($scope.edit.NAME)
}
如果我試圖像這樣一個它的工作,但我想打電話給在任何的NG-模型$範圍內的任何變化。 $ watch('edit.NAME',function(Value){ if($ scope.old.NAME!= $ scope.edit.NAME){ $ scope.old.NAME.append($ scope.edit.NAME) } –
然後你應該可以將'edit''改成''edit.NAME'' ...這是否有效? –
是的,但我只想使用編輯,以便如果用戶輸入任何域名d我的$ watch show工作 –