title: angularjs form not working when ng-app and ng-controller is declared in form tag
body: <p>When I declare the ng-app and ng-controller the form does not do validation.</p>
  
  <p>If I remove them then the form does basic validation, but I want to use controller logic to perform username and password validation and routing, which I cant use (as ng-controller is removed).</p>
  
  <p>What I am missing?</p>
  
  <pre><code>&lt;html ng-app&gt;
    &lt;head&gt;
      &lt;title&gt;My Angular App&lt;/title&gt;
      &lt;script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt; 
      document.write("\&lt;script src='http://code.jquery.com/jquery-latest.min.js' type='text/javascript'&gt;\&lt;\/script&gt;");
  &lt;/script&gt;
    &lt;script&gt;
  
  
  &lt;script&gt;
  var app = angular.module('myapp', []);
  app.controller('loginCtrl', function($scope, $location){
  $scope.loginCheck = function(){
  var uname = $scope.user.name;
  var pwd = $scope.user.password;
  if ( uname == 'admin' &amp;&amp; pwd =='admin123'){
  window.location.hash='#/dashboard';
  $location.path('/dashboard');
              }
              else $location.path('/about')
        };
  
  });
  &lt;/script&gt;
  
  &lt;body&gt;
      &lt;h3  align="center"&gt;Loginn&lt;/h3&gt;
  
          &lt;form   name="form" class="login" ng-app='myapp' ng-controller = 'loginCtrl' &gt;
  
  &lt;input placeholder="User Name"
         name="name" ng-model="user.name"  class="login-input" ng-model-options="{updateOn:'blur'}"
         required pattern=".{3,}" /&gt;
  &lt;div class="error-message" ng-show="form.name.$invalid &amp;&amp; !form.name.$pristine"&gt;
      We need a name with 3 chars or more.
  &lt;/div&gt;
  
  &lt;br&gt;
  
  &lt;input placeholder="E-mail"
         name="email" ng-model="user.email" class="login-input"  ng-model-options="{updateOn:'blur'}"
         required type="email"  /&gt;
  &lt;div class="error-message"
       ng-show="form.email.$invalid &amp;&amp; !form.email.$pristine"&gt;
      We need a valid e-mail address.
  &lt;/div&gt;
  
  &lt;br&gt;
  
  &lt;input type="password" class="login-input"  ng-model="user.password" name="uPassword" required placeholder='Password' ng-minlength="6" ng-maxlength="15" title="6 to 15 characters" /&gt;
  &lt;span class="error" ng-show="form.uPassword.$dirty &amp;&amp; form.uPassword.$error.minlength"&gt;Too short&lt;/span&gt;
  &lt;span ng-show="form.uPassword.$dirty &amp;&amp; form.uPassword.$error.required"&gt;Password required.&lt;/span&gt;&lt;br /&gt;
  
  &lt;input type="password" class="login-input"  ng-model="user.confirmpassword" name="ucPassword" required placeholder='Confirm Password' ng-minlength="6" ng-maxlength="15" title="6 to 15 characters" /&gt;
  &lt;span class="error" ng-show="form.ucPassword.$dirty &amp;&amp; form.ucPassword.$error.minlength"&gt;Too short&lt;/span&gt;
  &lt;span ng-show="form.ucPassword.$dirty &amp;&amp; form.ucPassword.$error.required"&gt;Retype password.&lt;/span&gt;
  &lt;div ng-show="(form.uPassword.$dirty &amp;&amp; form.ucPassword.$dirty) &amp;&amp; (user.password != user.confirmpassword)"&gt;
      &lt;span&gt;Password mismatched&lt;/span&gt;
  &lt;/div&gt;
  
  &lt;br&gt;
  
   &lt;input type="submit"   value ="Submit "  ng-click="loginCheck()" ng-disabled="form.$invalid"/&gt;
  
  &lt;/form&gt;
  
  
  
  &lt;/body&gt;
  </code></pre>
  
  <p>How can I add/specify ng-controller and ng-app in this form?</p>