HI我在IIS服務器上發佈AngularJS應用程序後出現問題 我相信這與JavaScript混淆和縮小有關,但我不知道如何解決它...
這是我app.js看怎麼樣
angular.module('app', ['LocalStorageModule', 'angular-loading-bar', 'smart-table', 'mgcrea.ngStrap', 'ngAnimate', 'ngSanitize', 'ngRoute', 'ui.router', 'LocalStorageModule', 'app.filters', 'app.services', 'app.directives', 'app.controllers'])
.config(['$stateProvider', '$locationProvider', function ($stateProvider, $locationProvider) {
$stateProvider
.state('home', {
url: '/',
layout: 'basic',
templateUrl: 'views/index',
controller: 'HomeCtrl'
})
.state('putninalozi', {
url: '/putninalozi',
layout: 'basic',
templateUrl: 'views/PutniNalozi',
controller: 'PutniNaloziCtrl'
})
.state('profil', {
url: '/profil',
layout: 'basic',
templateUrl: 'views/profil',
controller: 'ProfilCtrl'
})
.state('login', {
url: '/login',
layout: 'basic',
templateUrl: 'views/login',
controller: 'LoginCtrl'
})
.state('signup', {
url: '/signup',
layout: 'basic',
templateUrl: 'views/signup',
controller: 'SignUpCtrl'
})
.state('otherwise', {
url: '*path',
templateUrl: 'views/404',
controller: 'Error404Ctrl'
});
$locationProvider.html5Mode(true);
}])
.config(function ($httpProvider) {
$httpProvider.interceptors.push('authInterceptorService');
})
.run(['authService', '$templateCache', '$rootScope', '$state', '$stateParams', function (authService, $templateCache, $rootScope, $state, $stateParams) {
authService.fillAuthData();
$rootScope.$state = $state;
$rootScope.$stateParams = $stateParams;
}]);
再舉例來說,我的控制器的一個看起來像這樣
.controller('LoginCtrl', ['$scope', '$location', '$timeout', '$window', 'authService', function ($scope, $location, $timeout, $window, authService) {
$scope.loginData = {
userName: "",
password: ""
};
$scope.message = "";
$scope.login = function() {
authService.login($scope.loginData).then(function (response) {
$location.path('/putninalozi');
},
function (err) {
$scope.message = err.error_description;
});
};
}])
任何想法如何解決這個問題?感謝您的所有意見
我BundleCOnfig.cs看起來像這樣
public class BundleConfig
{
// For more information on bundling, visit http://go.microsoft.com/fwlink/?LinkId=301862
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new StyleBundle("~/content/css/app").Include("~/content/app.css")
.Include("~/content/custom.css")
.Include("~/content/loading-bar.css"));
// bundles.Add(new ScriptBundle("~/js/jquery").Include("~/scripts/vendor/jquery-{version}.js"));
bundles.Add(new ScriptBundle("~/js/app").Include(
"~/scripts/vendor/angular.min.js",
"~/scripts/vendor/smart-table.js",
"~/scripts/vendor/angular-strap.min.js",
"~/scripts/vendor/angular-strap.tpl.min.js",
"~/scripts/app.js",
"~/scripts/vendor/jquery-2.0.3.min.js",
"~/scripts/vendor/angular-ui-router.js",
"~/scripts/vendor/loading-bar.js",
"~/scripts/vendor/angular-animate.js",
"~/scripts/vendor/angular-route.js",
"~/scripts/vendor/angular-sanitize.min.js",
"~/scripts/vendor/angular-local-storage.min.js",
"~/scripts/vendor/bootstrap.js",
"~/scripts/controllers.js",
"~/scripts/filters.js",
"~/scripts/services.js",
"~/scripts/directives.js"));
}
}
聽起來像微小的問題添加BundleTable.EnableOptimizations =假。你設置了'BundleTable.EnableOptimizations = true;'? – sjokkogutten
不,我沒有代碼的和平 –
你有一個'BundleConfig.cs'所有的JavaScript文件添加到捆綁? – sjokkogutten