Advertisement
Guest User

Untitled

a guest
Sep 9th, 2016
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.55 KB | None | 0 0
  1. var myapp = angular
  2. .module("mainModule", ['ngRoute'])
  3. .config(function ($routeProvider, $locationProvider) {
  4. $routeProvider
  5.  
  6. .when("/login", {
  7. templateUrl: "Templates/login.html",
  8. controller: "LoginController",
  9. controllerAs: "loginctrl",
  10. caseInsensitiveMatch: true
  11. })
  12.  
  13. .when("/Home", {
  14. templateUrl: "Templates/Home.html",
  15. controller: "HomeController",
  16. controllerAs: "Homectrl",
  17. caseInsensitiveMatch: true
  18. })
  19. })
  20. .controller("LoginController", function ($scope, $location) {
  21. $scope.username = "";
  22. $scope.password = "";
  23. $scope.Login = function () {
  24. if ($scope.username == "a" || $scope.password == "a") {
  25. alert("SuccessFully Logged in")
  26. $location.path("/Home");
  27.  
  28. }
  29. //alert('Hello'+$scope.username+""+$scope.password);
  30. }
  31. })
  32. .controller("HomeController", function ($scope) {
  33.  
  34.  
  35. })
  36.  
  37. <!DOCTYPE html>
  38. <html xmlns="http://www.w3.org/1999/xhtml" ng-app="mainModule">
  39. <head>
  40. <title></title>
  41. <script src="../Scripts/angular.js"></script>
  42. <script src="../Scripts/angular-route.js"></script>
  43. <script src="../index.js"></script>
  44.  
  45. </head>
  46. <body>
  47. <div ng-controller="LoginController">
  48. <table>
  49. <tbody>
  50. <tr>
  51. <th>UserName:</th>
  52. <th><input type="text" value="" ng-model="username" /></th>
  53. </tr>
  54. <tr>
  55. <th>Password:</th>
  56. <th><input type="password" value="" ng-model="password" /></th>
  57. </tr>
  58. <tr>
  59. <th><button name="Submit" ng-click="Login()"> Submit</button>
  60. </tr>
  61. </tbody>
  62. </table>
  63. </div>
  64. </body>
  65. </html>
  66.  
  67. <!DOCTYPE html>
  68. <html xmlns="http://www.w3.org/1999/xhtml ng-app=" mainmodule">
  69. <head>
  70. <title></title>
  71. <script src="../Scripts/angular.js"></script>
  72. <script src="../Scripts/angular-route.js"></script>
  73. <script src="../index.js"></script>
  74. </head>
  75. <body ng-controller="HomeController">
  76. hi
  77. </body>
  78. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement