0

这就是我所拥有的。

  <form action="/asvabo/ChangeCustomerRegister.do" method="post"  
    name="CustomerRegisterForm">
    ...
      <input ... type="text" ... name="order.id" pattern="[0-9]*" required 
        ng-model="orderid" ng-trim="true"/>

      <!-- Label for show that the input is required -->
      <span class="error" 
         ng-show="CustomerRegisterForm.order.id.$error.required">Required!
      </span>
     ....
    </form>

我认为,NAME 属性有问题。如果我在两者中都使用 orderid,则输入标签和以下错误条件将起作用。但是我们使用 Struts,我需要 NAME 属性,比如xxxx.yyyy

有没有办法在 der ng-showexprssion 中使用这种语法?

感谢您的评论。

4

1 回答 1

2

我查看了表单控制器源代码

form.$addControl = function(control) {
  // Breaking change - before, inputs whose name was "hasOwnProperty" were quietly ignored
  // and not added to the scope.  Now we throw an error.
  assertNotHasOwnProperty(control.$name, 'input');
  controls.push(control);

  if (control.$name) {
    form[control.$name] = control;
  }
};

在您的情况下,输入是control.$name === "order.id",所以会发生以下情况:

  form["order.id"] = control;

解决方案是像这样引用控件:

<span class="error" 
      ng-show="CustomerRegisterForm['order.id'].$error.required">Required!
</span>
于 2014-02-17T14:13:43.250 回答