Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var app = angular.module("myApp", ['ngRoute']);
- var user = {};
- var user_arr = [];
- app.config(function ($routeProvider) {
- $routeProvider.when('/', {
- templateUrl: 'login.html',
- controller:'loginCntrl'
- }).when('/register', {
- templateUrl: 'register.html',
- controller:'registerCntrl'
- }).when('/homepage', {
- templateUrl: 'homePage.html',
- controller:'homePageCntrl'
- }).when('/profile', {
- templateUrl: 'profile.html',
- controller:'profileCntrl'
- }).when('/messages', {
- templateUrl: 'messages.html',
- controller:'messageCntrl'
- }).otherwise({
- redirectTo: "/login"
- });
- });
- app.controller('loginCntrl', ['$scope', '$location', function ($scope, $location) {
- var current_user_Obj = {};
- $scope.Login = function () {
- var user_name = $scope.usernameL;
- var pwd = $scope.passwordL;
- for (var i = 0; i < localStorage.length; i++) {
- var val = JSON.parse(localStorage.getItem('userlist'));
- if (val.username == user_name && val.password == pwd) {
- alert('Login successful');
- current_user_Obj = val;
- $location.path("/homepage");
- }
- }
- }
- }
- ]);
- app.controller('registerCntrl', ['$scope', '$location', function ($scope, $location) {
- $scope.CreateAccount = function () {
- user.username = $scope.userName;
- user.firstname = $scope.firstName;
- user.lastname = $scope.lastName;
- user.phone = $scope.phone;
- user.email = $scope.email;
- user.gender = $scope.myVar;
- user.password = $scope.password;
- user_arr.push(user);
- localStorage.setItem('userlist', JSON.stringify(user));
- }
- $scope.goBack = function () {
- $location.path("/");
- }
- }]);
- app.controller('homePageCntrl', ['$scope', '$location', function ($scope,$location) {
- $scope.go2Profile = function () {
- $location.path('/profile');
- }
- $scope.go2Messages = function () {
- $location.path('/messages');
- }
- }])
- app.controller('profileCntrl', ['$scope', '$location', function ($scope, $location) {
- }])
- app.controller('messageCntrl', ['$scope', '$location', function ($scope, $location) {
- }])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement