-2
我已經創建了簡單的登錄表單並對其執行驗證,但問題是驗證發生在頁面加載期間。我的oode在這裏。Angular js:顯示錯誤信息,直到頁面加載完成?
<body ng-controller="myCont">
<form name="myForm" novalidate>
<h2 align="center">Add The Item Here</h2> \t
<table align="center" border="2">
<div class="control-group">
<div class="controls"> \t \t
\t \t \t <tr>
\t \t \t \t <td>pid</td>
\t \t \t \t \t <td><input type="number" name="pid" ng-model="user.pid" ng-maxlength="3" required="pid" ></td>
<td ng-show="myForm.pid.$touched && myForm.pid.$invalid"></td>
<td ng-show="myForm.pid.$error.required" style="color:red">Enter Pid</td>
<td ng-show="myForm.pid.$error.maxlength" style="color:red">Only 3 digits for pid</td>
\t \t \t \t </tr>
<tr>
\t \t \t \t <td>pname</td>
\t \t \t \t \t <td><input type="text" name="pname" ng-model="user.pname" required="pname"></td>
\t \t \t \t \t <td style="color:red" ng-show="myForm.pname.$touched && myForm.pname.$invalid"></td>
<td ng-show="myForm.pname.$error.required" style="color:red">Pname is required.</td>
</tr>
\t <tr>
\t \t \t \t \t <td>pcost</td>
\t \t \t \t \t <td><input type="number" name="pcost" ng-model="user.pcost" required="pcost"></td>
\t \t \t \t \t <td style="color:red" ng-show="myForm.pcost.$touched && myForm.pcost.$invalid">
<td ng-show="myForm.pcost.$error.required" style="color:red">Pcost is required.</td>
</tr>
<div ng-repeat="x in result track by $index"></div>
\t \t \t \t <tr>
\t \t \t <td>AddData<input type="submit" ng-disabled="myForm.$invalid" ng-click="addAll()">
</td>
\t \t \t <td><input type="reset" name="reset" value="reset"></td>
\t \t \t </tr>
\t \t \t
</div>
</div>
</table>
</form>
</body>
你需要給我們的更多信息走吧,我們無法幫助你在那裏給你的東西。 – GrandMasterFlush
爲了在這個論壇獲得幫助,您需要先爲我們提供幫助。一個示例代碼將很好開始。 –
兩個人認爲:也許角度沒有初始化,嘗試把一個{{anyVarName}} ... ...,如果你能看到表達式,角度出來。如果角度沒問題,看看ng-cloak。驗證表單是否有名稱(驗證需要)並且輸入具有名稱和ng模型。 –