Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- angular.module('edc-service.controllers', [])
- .controller('AppCtrl', ['$scope', '$state', 'authService', function($scope, $state, authService) {
- $scope.logout = function() {
- $state.go('login');
- authService.clearUser();
- };
- // Perform the login action when the user submits the login form
- $scope.doLogin = function() {
- console.log('Doing login', $scope.loginData);
- // Simulate a login delay. Remove this and replace with your login
- // code if using a login system
- $timeout(function() {
- $scope.closeLogin();
- }, 1000);
- };
- }])
- .controller('JobsCtrl', ['$scope', '$state', 'jobFactory', 'authService',
- function($scope, $state, jobFactory, authService) {
- var jobs = this;
- $scope.$on('$ionicView.loaded', function () {
- var user = authService.currentUser();
- if (!user) {
- $state.go('login');
- }
- else {
- jobs.getJobs(user);
- }
- });
- jobs.getJobs = function (user) {
- jobs.loading = true;
- jobFactory.getJobs(user)
- .then(function (data) {
- jobs.jobList = data;
- jobs.loading = false;
- })
- .then(function (error) {
- jobs.loading = false;
- });
- }
- }])
- .controller('ProfileCtrl', ['$scope', '$state', 'authService',
- function($scope, $state, authService) {
- var profile = this;
- $scope.$on('$ionicView.loaded', function () {
- profile.user = authService.currentUser();
- if (!profile.user) {
- $state.go('login');
- }
- });
- }])
- .controller('LoginCtrl', ['$scope', '$state', 'apiURL', 'contactInfo', 'authService',
- function($scope, $state, apiURL, contactInfo, authService) {
- var login = this;
- $scope.$on('$ionicView.loaded', function () {
- login.loading = true;
- login.user = {
- userName: "skempner",
- password: "experian.1"
- }
- login.contactInfo = contactInfo;
- login.loading = false;
- });
- login.login = function (user) {
- login.loading = true;
- authService.login(user)
- .then (function (data) {
- login.password = "";
- $state.go("app.jobs");
- login.loading = false;
- })
- .then (function (error) {
- login.loading = false;
- });
- }
- }])
- ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement