SHARE
TWEET

Untitled

a guest Oct 4th, 2017 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var app = angular.module('myApp', [
  2. "toastr",
  3. "ui.bootstrap",
  4. "ngRoute",
  5. "datatables",
  6. "ngMaterial",
  7. "ngMessages",
  8. "material.svgAssetsCache"
  9. ]);
  10.  
  11. app.config(["$routeProvider", "$locationProvider",
  12. function ($routeProvider, $locationProvider) {
  13.     console.log('$routeProvider' + JSON.stringify($routeProvider));
  14.     console.log('$locationProvider' + $locationProvider);
  15.     //return
  16.     $routeProvider.when("/login",
  17.         {
  18.             redirectTo: "/login"
  19.         }).when("/Home",
  20.         {
  21.             redirectTo: "~/Home/Index/"
  22.             //controller: "MyCtrl"
  23.         }).when("/user",
  24.         {
  25.             redirectTo: "/User/"
  26.         }).when("/adduser",
  27.         {
  28.             redirectTo: "/User/User"
  29.         }).when("/role",
  30.         {
  31.             redirectTo: "/Role/"
  32.         }).when("/addrole",
  33.         {
  34.             redirectTo: "/Role/AddRole"
  35.         }).when("/settings",
  36.         {
  37.             redirectTo: "/Settings/"
  38.         }).when("/Editsettings",
  39.         {
  40.             redirectTo: "/Settings/Edit/"
  41.         }).when("/uploadData",
  42.         {
  43.             redirectTo: "/UploadDataFile/"
  44.         }).otherwise(
  45.         {
  46.             redirectTo: '/Test/Index'
  47.         });
  48.     $locationProvider.html5Mode({
  49.         enabled: true,
  50.         requireBase: false
  51.     }).hashPrefix('!'); //Remove the '#' from URL.  
  52. }])
  53.    
  54. app.controller('LoginCtrl', function ($scope, $location, $http, $window) {
  55. $scope.ddlDomain = [ 'AS', 'EU', 'LA'];
  56. $scope.Domain = $scope.ddlDomain[0].value;
  57.  
  58. // send to your controller
  59. $scope.LoginClick = function () {
  60.     var User = {
  61.         UserId: $scope.UserId,
  62.         Password: $scope.Password,
  63.         Domain: $scope.Domain
  64.     }
  65.  
  66.     $http({
  67.         method: "post",
  68.         url: "/Login/SSOLogin",
  69.         data: { 'user': User }
  70.     }).then(function (response) {
  71.  
  72.         if ((response.data.Message == "") || (response.data.Message == null)) {                              
  73.             $location.path('/Home');
  74.  
  75.             if (!$scope.$$phase) {
  76.                 //$digest or $apply
  77.                 $scope.$apply();    
  78.             }
  79.         } else {
  80.             $scope.errormsg = response.data.Message;
  81.         }
  82.         // handle success here
  83.     }, function (response) {
  84.         console.log("err" + response.data);
  85.             // handle error here
  86.         });
  87. }
  88. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top