【问题标题】:setPristine for a single input field单个输入字段的 setPristine
【发布时间】:2016-09-22 04:52:21
【问题描述】:

我正在尝试对表单中的单个输入字段使用 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">

【问题讨论】:

标签: angularjs


【解决方案1】:

或许你可以试试这个。

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

看看这个plunker。它可能对你有用。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-19
    • 1970-01-01
    • 2017-11-09
    • 2015-09-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-17
    相关资源
    最近更新 更多