Created
January 8, 2016 16:06
-
-
Save vinay13/82e9dd1ad32316d1ee87 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--------- | |
index.html | |
----- | |
<html> | |
<head> | |
<script src="http://code.angularjs.org/1.2.13/angular.js"></script> | |
<script src="//cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.2.8/angular-ui-router.min.js"></script> | |
</head> | |
<body ng-app="mainApp" ng-controller="LoginCtrl"> | |
<div ui-view=""></div> | |
<script> | |
var app=angular.module('mainApp',['ui.router']); | |
app.config(function($stateProvider,$urlRouterProvider){ | |
$urlRouterProvider.otherwise("/login"); | |
$stateProvider | |
.state('state1', { | |
url: "/dashboard", | |
templateUrl: "app.html" | |
}) | |
.state('login', { | |
url: "/login", | |
templateUrl: "login.html" | |
}); | |
}); | |
app.controller('LoginCtrl',function($rootScope,$scope,$state){ | |
$rootScope.username = "vinay"; | |
$rootScope.password= "singh1233"; | |
$scope.loginform=function(user) { | |
if($rootScope.username === user.username2 && $rootScope.password === user.password2 ) | |
{ | |
alert('login succesfully,welcome to dashboard'); | |
$state.go('state1'); | |
} | |
else{ | |
alert('cannot login'); | |
} | |
}; | |
//console.log('LoginFactory',LoginFactory); | |
}); | |
app.controller('AppCtrl',function($scope) { | |
$scope.message="helllllo vinay "; | |
}); | |
</script> | |
</body> | |
</html> | |
------------------------------------------------------------------------------------ | |
app.html | |
------------------- | |
<h1>this is app.html page</h1> | |
--------------- | |
login.html | |
------------ | |
<h1>LoGIN</h1> | |
<input type="text" ng-model="user.username2" > | |
<input type="text" ng-model="user.password2"> | |
<button ng-click="loginform(user)">submit</button> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment