简体   繁体   中英

angular js ui-route not working after minify angular app

Hello I have made app using angular, I have used ui-router for routing, I have minified the whole angular app using gulp-uglify.

After minifying app, my child route(nested route) of ui-router is not rendering view, main parent routes are working properly.

Can some one suggest me what to do here is my route sample:

.state('masterPage', {
  url: "",
  abstract: true,
  templateUrl: 'src/app/Client/common/fullPage.html'
}).state('masterPage.userProfile.dashboard', {
  url: "/dashboard",
  templateUrl: "src/app/Client/userProfile/dashboard/index.html",
  controller: "userDashboard",
  controllerAs: 'vm'
})

When you minify the the app, It breaks the dependency injection. After minifying $scope is no longer $scope, they are minified variable like e or a. Which doesn't makes any sense for angularJS. To resolve this you can use ng-annotate for gulp and grunt and comment functions that need automated dependency injection using /* @ngInject */

Go through this link for more details about it. AngularJs Minification and Annotation

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM