2016-09-22 50 views
3

我想爲我的表單中的單個輸入字段使用setPristine方法。有一些方法可以爲整個表單做到這一點,但我只想在表單中的一個輸入字段中執行此操作。如何才能做到這一點?setPristine爲單個輸入字段

我嘗試了這種方式

$scope.merchantDetails.customer_id.$setPristine = true; 

但沒有奏效。

這是我想在某些功能上將其設置爲原始狀態的輸入字段。

<input class="form-control" id="id_customer_id" name="customer_id" placeholder="Auto-generated if empty" title="" type="text" maxlength="8" ng-keydown="check();" ng-model="customer.customerId"> 
+0

可能的重複http://stackoverflow.com/questions/26837258/set-individual-input-element-to-ng-pristine –

回答

0

也許你可以試試這個。

$scope.form.customer_id.$setPristine(false); 

看看這個plunker。它可能適用於你。