2016-09-22 51 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。它可能适用于你。