Guest User

Untitled

a guest
Jan 18th, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. <html>
  2. <head>
  3. <script
  4. src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js">
  5. </script>
  6. <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular-
  7. route.js"></script>
  8. <script src="maincontroller.js"></script>
  9. </head>
  10. <body>
  11. <div ng-view>
  12. </div>
  13. </body>
  14. </html>
  15.  
  16. var app = angular.module('myapp', ['ngRoute']);
  17. app.config(function($routeProvider) {
  18. $routeProvider
  19. .when('/', {
  20. templateUrl: 'login.html',
  21. controller: 'maincontroller'
  22. })
  23. .when('/dashboard', {
  24. templateUrl: 'dashboard.html'
  25. })
  26. .otherwise('/', {
  27. templateUrl: '/'
  28. })
  29. });
  30. app.controller('maincontroller', function($scope, $location) {
  31. $scope.submit = function($scope) {
  32. var username = $scope.username;
  33. var password = $scope.password;
  34. if ($scope.username == 'ashok' && $scope.password == 'ashok') {
  35. $location.path('/dashboard');
  36. } else {
  37. windows.alert('wrong stuff');
  38. }
  39. };
  40. });
  41.  
  42. <div ng-controller="maincontrol">
  43.  
  44.  
  45. <form action="/" name="formgroup">
  46. <label>Username:<input type="text" id="username" ng-model="username"/></label><br>
  47. <label>Password:<input type="password" id="password" ng-model="password"/></label><br>
  48. <button type="button" ng-click="submit()">Login</button>
  49. </form>
Add Comment
Please, Sign In to add comment