簡體   English   中英

angularJS - ng-show - 錯誤

[英]angularJS - ng-show - error

這就是我所擁有的。

  <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,我需要像xxxx.yyyy這樣的NAME屬性

有沒有辦法在der ng-show exprssion中使用這種語法?

感謝您的評論。

我查看了表單控制器的源代碼

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>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM