setPristine用于单个输入字段

Alp*_*Dog 7 angularjs

我正在尝试将setPristine方法用于表单中的单个输入字段.有一些方法可以为整个表单执行此操作,但我想只对我的表单中的一个输入字段执行此操作.如何执行此操作?

我试过这种方式

$scope.merchantDetails.customer_id.$setPristine = true;
Run Code Online (Sandbox Code Playgroud)

但没有奏效.

这是我想在某个函数上将其设置为pristine状态的输入字段.

<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">
Run Code Online (Sandbox Code Playgroud)

小智 4

也许你可以尝试这个。

$scope.form.customer_id.$setPristine(false);
Run Code Online (Sandbox Code Playgroud)

看看这个笨蛋。它可能对你有用。