setPristine用于单个输入字段

时间:2022-05-14 20:08:56

I'm trying to use setPristine method for a single input field in my form. There are ways to do this for the entire form but i want to do this only to one input field in my form.How can i do this?

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

I tried it this way

我这样试过

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

But did not work.

但没有奏效。

This is the input field i want to set it to pristine state on some function.

这是我希望在某些功能上将其设置为原始状态的输入字段。

<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">

1 个解决方案

#1


2  

Probably you can try this.

也许你可以试试这个。

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

Have a look into this plunker.It might work for u.

看看这个plunker.It可能适合你。

#1


2  

Probably you can try this.

也许你可以试试这个。

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

Have a look into this plunker.It might work for u.

看看这个plunker.It可能适合你。