2017-09-16 16 views
1

在「ng顯示」期間,文本沒有出現在GUI上。幫我說出代碼中的錯誤。在ng顯示期間,文本沒有出現在UI上

<div ng-app="myApp" ng-controller="myCntrl"> 
     <form name="nishant" ng-submit="submit()"> 
      <div> 
       Name : <input type="text" name="name" ng-minlenght="5" 
        required="required"> <span 
        ng-show="nishant.name.$error.minlength">required12</span> 
      </div> 
      <button name="button" type="submit">SUbmit</button> 
     </form> 

     <script type="text/javascript"> 
      var app = angular.module("myApp", []); 
      app.controller("myCntrl", function($scope) { 
       alert("nishant"); 

       $scope.submit = function() { 
        alert("in the submit"); 
       } 
      }); 
     </script> 
</div> 

請看看爲什麼ng-show沒有出現在屏幕上。如果我刪除我的控制器它出現。

回答

0

更新:

使用ng-show顯示消息終極密碼。

JSFiddle Demo

答:

您需要添加一個ng-model使用表單驗證(nishant.name.$error.minlength)。你也有拼錯ng-minlength

var app = angular.module('myApp', []); 
 

 
app.controller('MyController', function MyController($scope) { 
 
    //alert("nishant"); 
 

 
    $scope.submit = function() { 
 
    alert("in the submit"); 
 
    } 
 
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script> 
 
<div ng-controller='MyController' ng-app="myApp"> 
 
    <form name="nishant" ng-submit="submit()"> 
 
    <div> 
 
     Name : 
 
     <input type="text" name="name" ng-minlength="5" required="required" ng-model="name"> <span ng-show="nishant.name.$error.minlength">required12</span> 
 
    </div> 
 
    <button name="button" type="submit">SUbmit</button> 
 
    </form> 
 
</div>

+0

沒有增加,甚至NG-模型還我沒有得到過我的screen.Kindly,幫助NG秀封郵件後。 –

+0

@NishantSingh你糾正了'ng-minlength'你能提供一個JSFiddle嗎? –

+0

雅我也coorected,如果我加入控制器,只有它不出現。什麼是JSFiddle我不知道。 –

相關問題