Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <script
- src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js">
- </script>
- <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular-
- route.js"></script>
- <script src="maincontroller.js"></script>
- </head>
- <body>
- <div ng-view>
- </div>
- </body>
- </html>
- var app = angular.module('myapp', ['ngRoute']);
- app.config(function($routeProvider) {
- $routeProvider
- .when('/', {
- templateUrl: 'login.html',
- controller: 'maincontroller'
- })
- .when('/dashboard', {
- templateUrl: 'dashboard.html'
- })
- .otherwise('/', {
- templateUrl: '/'
- })
- });
- app.controller('maincontroller', function($scope, $location) {
- $scope.submit = function($scope) {
- var username = $scope.username;
- var password = $scope.password;
- if ($scope.username == 'ashok' && $scope.password == 'ashok') {
- $location.path('/dashboard');
- } else {
- windows.alert('wrong stuff');
- }
- };
- });
- <div ng-controller="maincontrol">
- <form action="/" name="formgroup">
- <label>Username:<input type="text" id="username" ng-model="username"/></label><br>
- <label>Password:<input type="password" id="password" ng-model="password"/></label><br>
- <button type="button" ng-click="submit()">Login</button>
- </form>
Add Comment
Please, Sign In to add comment