Last active
January 14, 2016 13:31
-
-
Save vinay13/1384e80dcba1d4f5c14e 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
<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> | |
<script src="http://code.angularjs.org/1.2.13/angular-resource.js"></script> | |
</head> | |
<body ng-app="mainApp"> | |
<div ui-view=""></div> | |
<script> | |
var app=angular.module('mainApp',['ui.router','ngResource']); | |
app.config(function($stateProvider,$urlRouterProvider){ | |
$urlRouterProvider.otherwise("/customers"); | |
$stateProvider | |
.state('customers', { | |
url: "/customers", | |
template: '<div ui-view ></div>', | |
resolve: { | |
// A string value resolves to a service | |
customersResource: 'customersResource', | |
// A function value resolves to the return | |
// value of the function | |
customer: function(customersResource, $stateParams){ | |
// Extract customer ID from $stateParams | |
var customerId = $stateParams.customerId; | |
// Return a promise to make sure the customer is completely | |
// resolved before the controller is instantiated | |
return customersResource.query({customerId: customerId}).$promise; | |
} | |
}, | |
controller : 'customersCtrl' | |
}) | |
.state('customers.doctor', { | |
url: "/doctor", | |
templateUrl: "app.html", | |
controller : 'AppCtrl' | |
}); | |
}); | |
app.controller('customersCtrl', ['$scope','customer',function($scope, customer, $state){ | |
// Log customers when controller executes | |
console.log(customer); | |
// Assign customers to scope | |
$scope.customers = customer; | |
}]); | |
app.factory('customersResource', ['$resource', function($resource) { | |
return $resource('http://urbanfixerz.pythonanywhere.com/customer/customers/:customerId', {customerId: 1 }) | |
}]); | |
/* | |
app.factory('Post1',function($resource){ | |
//extra code | |
var method1 = function(){ | |
return $resource("http://urbanfixerz.pythonanywhere.com/customer/customers/:id"); | |
}; | |
var method2 = function(){ | |
return $resource("http://urbanfixerz.pythonanywhere.com/jobs/jobdetails/:id") | |
}; | |
return { | |
method1, | |
method2 | |
}; | |
}); | |
app.controller('LoginCtrl',function($rootScope,$scope,Post1,$state,$http,$resource){ | |
Post1.method1().get({ id : 1 },function(data){ | |
$scope.post = data; | |
console.log($scope.post); | |
}); | |
Post1.method2().get({ id : 2 },function(data){ | |
$scope.post = data; | |
console.log($scope.post); | |
}); | |
}); | |
*/ | |
/* | |
$scope.loginform=function(user) { | |
$http.delete('http://urbanfixerz.pythonanywhere.com/customer/customers/'+ user.id) | |
.then(function (response) { | |
$rootScope.names = response.data ; | |
console.log($rootScope.names); | |
}); | |
// console.log($scope.names.length); | |
// console.log($scope.names[1]); | |
var obj=$scope.names.length; | |
for(i=0;i< obj ;i++){ | |
if($scope.names[i].username === user.username2) | |
{ | |
var k = i; | |
} | |
} | |
if($scope.names[k].username === user.username2 && $scope.names[k].password === user.password2) | |
{ | |
if($scope.names[k].usergroup === 'patient') | |
{ | |
alert('login succesfully,welcome to patient dashboard'); | |
$scope.useris= $scope.names[k].username; | |
$state.go('patient'); | |
} | |
else if($scope.names[k].usergroup === 'doctor') | |
{ | |
alert('login succesfully,welcome to doctor dashboard'); | |
$scope.useris= $scope.names[k].username; | |
$state.go('doctor'); | |
} | |
} | |
else{ | |
alert('cannot login, Try again'); | |
} | |
}; | |
}); | |
*/ | |
/* | |
for(i=0;i<$scope.credentials.length;i++){ | |
if($scope.credentials[i].username === user.username2) | |
{ | |
var k = i; | |
} | |
} | |
if( $rootScope.credentials[k].username === user.username2 && $rootScope.credentials[k].password === user.password2 ) | |
{ | |
if($rootScope.credentials[k].group === 'patient') | |
{ | |
alert('login succesfully,welcome to patient dashboard'); | |
$scope.useris= $scope.credentials[k].username; | |
$state.go('patient'); | |
} | |
else if($rootScope.credentials[k].group === 'doctor') | |
{ | |
alert('login succesfully,welcome to doctor dashboard'); | |
$scope.useris= $scope.credentials[k].username; | |
$state.go('doctor'); | |
} | |
} | |
else{ | |
alert('cannot login, Try again'); | |
} | |
*/ | |
app.controller('AppCtrl',function($scope) { | |
$scope.message="helllllo vinay "; | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment