Question

that's what I have.

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

I think, there is a problem with the NAME attribute. If i use orderid in both, the input-tag and the following error condition it works. But we work with Struts and i need the NAME attribute like xxxx.yyyy

Is there a way to use this syntax in der ng-show exprssion?

Thanks for comments.

Was it helpful?

Solution

I looked inside the form controller source code:

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;
  }
};

In your case, the input's control.$name === "order.id", so this what happens:

  form["order.id"] = control;

The solution is to refer the control like so:

<span class="error" 
      ng-show="CustomerRegisterForm['order.id'].$error.required">Required!
</span>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top