Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- cb_application.config(function($stateProvider, $urlRouterProvider) {
- $stateProvider
- .state('dashboard', {url: '/dashboard',views: {'menuContent': {templateUrl: 'modules/dashboard.html',controller:'admin_dashboard'}}})
- .state('configuration', {url: '/add-static-ip',views: {'menuContent': {templateUrl: 'modules/configuration.html',controller: 'admin_view_static_ip'}}})
- .state('support', {url: '/support',views: {'menuContent': {templateUrl: 'modules/support.html',controller: 'admin_support'}}})
- .state('services', {url: '/servers',views: {'menuContent': {templateUrl: 'modules/services.html',controller: 'admin_view_server'}}})
- .state('cards', {url: '/cards',views: {'menuContent': {templateUrl: 'modules/cards.html',controller: 'admin_cards'}}})
- .state('profiles', {url: '/profiles',views: {'menuContent': {templateUrl: 'modules/profiles.html',controller: 'admin_view_profiles'}}})
- .state('people', {url: '/people',views: {'menuContent': {templateUrl: 'modules/people.html',controller: 'admin_people'}}})
- .state('show_dealers', {url: '/people/dealers'})
- .state('show_resellers', {url: '/people/resellers'})
- .state('people_detail', {url: '/people/:type/:id',views: {'menuContent': {templateUrl: 'modules/people_detail.html',controller: 'people_detail'}}})
- .state('invoices', {url: '/invoices',views: {'menuContent': {templateUrl: 'modules/invoices.html'}}})
- /*Login state*/
- .state('login', {
- url: '/login',
- templateUrl: 'modules/login.html',
- controller: 'LoginCtrl'
- })
- // Go back to cb's home
- $urlRouterProvider.otherwise('/login');
- });
- <ion-view view-title="Login" scroll="false">
- <ion-content>
- <form ng-submit="login()">
- <div class="list list-inset">
- <label class="item item-input">
- <input type="text" placeholder="Username" ng-model="data.username">
- </label>
- <label class="item item-input">
- <input type="password" placeholder="Password" ng-model="data.password">
- </label>
- </div>
- <button class="button button-block button-calm" type="submit">Login</button>
- </form>
- </ion-content>
- cb_application.controller('LoginCtrl', function($scope, LoginService, $ionicPopup, $state) {
- $scope.data = {};
- $scope.login = function() {
- LoginService.loginUser($scope.data.username, $scope.data.password).success(function(data) {
- $state.go('dashboard');
- }).error(function(data) {
- var alertPopup = $ionicPopup.alert({
- title: 'Login failed!',
- template: 'Please check your credentials!'
- });
- });
- }
- })
- .service('LoginService', function($q) {
- return {
- loginUser: function(username, password) {
- var deferred = $q.defer();
- var promise = deferred.promise;
- if (username == 'admin' && password == 'admin') {
- deferred.resolve('Welcome ' + username + '!');
- } else {
- deferred.reject('Wrong credentials.');
- }
- promise.success = function(fn) {
- promise.then(fn);
- return promise;
- }
- promise.error = function(fn) {
- promise.then(null, fn);
- return promise;
- }
- return promise;
- }
- }
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement