title: Angular JS Redirecting to another page
body: <p>I am working on angular js on a login form. If user name and password is correct then it should redirect to a success page. I am displaying a message for now but got struck on how to redirect to a success page once user enter correct credentials. any help ?</p>
  
  <pre><code>LOGIN.html :
  
  &lt;!DOCTYPE html&gt;
  &lt;html ng-app=""&gt;
  &lt;head&gt;
      &lt;script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js"&gt;&lt;/script&gt;
      &lt;script src="Controller.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;body ng-controller="LoginCheckController"&gt;
      &lt;h1&gt;Login Page&lt;/h1&gt;
      &lt;hr /&gt;
      UserName : 
      &lt;input type="text" ng-model="txtUname" required/&gt;&lt;br /&gt;
      Password  :
      &lt;input type="password" ng-model="txtPwd" required/&gt;&lt;br /&gt;
  
      &lt;input type="submit" value="Submit" ng-click="LoginCheck()" /&gt;&lt;br /&gt;
      &lt;!--    &lt;button ng-click="go('/Successpage')"&gt;Submit&lt;/button&gt;--&gt;
      &lt;br /&gt;
      &lt;div ng-repeat="x in users"&gt;
  
          &lt;div ng-if="txtUname === x.UserName &amp;&amp; txtPwd === x.Password"&gt;
              You entered UserName and Password correctly.
          &lt;/div&gt;
  
          &lt;div ng-if="txtUname === '' &amp;&amp; txtUname !== x.UserName &amp;&amp; txtPwd !== x.Password"&gt;
              You entered UserName and Password Incorrectly.
          &lt;/div&gt;
      &lt;/div&gt;
  
  
  CONTROLLER . js :
  
  function LoginCheckController($scope) {
  
              $scope.users = [
      { UserName: 'chandra', Password: 'hello' },
      { UserName: 'Harish', Password: 'hi' },
      { UserName: 'Chinthu', Password: 'hi' },
              ];
              $scope.go = function (path) {
                  $location.path("/SuccessPage");
              };                 
  
          }
  
  
  
  REGISTRATION . html :
  
  
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js"&gt;&lt;/script&gt;
      &lt;script src="RegistrationController.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
      &lt;h1&gt;Registration Page&lt;/h1&gt;
      &lt;hr /&gt;
      &lt;div ng-app="myApp"&gt;
          UserName : 
          &lt;input type="text" ng-model="Uname" /&gt;&lt;br /&gt;
          New Password  :
          &lt;input type="password" ng-model="Pwd" /&gt;&lt;br /&gt;
          Re-enter Password  :
          &lt;input type="password" ng-model="Pwd" /&gt;&lt;br /&gt;
  
          &lt;div ng-controller="DemoController"&gt;
              &lt;div&gt;
                 Gender : &lt;select ng-model="correctlySelected" ng-options="opt as opt.label for opt in options"&gt;
                  &lt;/select&gt;               
              &lt;/div&gt;
              &lt;br /&gt;
  
            Address : &lt;br /&gt;
              &lt;textarea rows="3" cols="20"&gt;&lt;/textarea&gt;
  
              &lt;div&gt;
                  State : &lt;select ng-model="correctlySelected" ng-options="opt as opt.label for opt in states"&gt;
                  &lt;/select&gt; 
              &lt;/div&gt;
  
              &lt;div&gt;
                  City : &lt;select ng-model="correctlySelected" ng-options="opt as opt.label for opt in cities"&gt;
                  &lt;/select&gt; 
              &lt;/div&gt;       
              &lt;input type="Submit" name="btn" value="Register" /&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  
  
  REGISTRATIONCONTROLLER . js :
  
  angular.module('myApp', []).controller('DemoController', function ($scope) {
  
      $scope.options = [
        { label: 'Male' },
        { label: 'Female' }
      ];
  
      $scope.cities = [
        { label: 'Mahabubnagar' },
        { label: 'Ranga Reddy' },
        { label: 'Nalgonda' },
        { label: 'Vizag' },
        { label: 'Karnool' },
        { label: 'Kadapa' },
        { label: 'Chennai' },
        { label: 'abc' },
        { label: 'xyz' }
      ];
  
      $scope.states = [
       { label: 'Telangana' },
       { label: 'Andhrapradesh' },
       { label: 'Tamilanadu' },     
      ];
  
  });
  </code></pre>