javascript - 缩小 Angular 应用程序后, Angular js ui-route 不起作用

标签 javascript angularjs angular-ui-router

您好,我使用 Angular 制作了应用程序,我使用 ui-router 进行路由,我使用 gulp-uglify 缩小了整个 Angular 应用程序。

缩小应用程序后,ui-router 的子路由(嵌套路由)未渲染 View ,主要父路由工作正常。

有人可以建议我在我的路线示例中做什么:

.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'
})

最佳答案

当您缩小应用程序时,它会破坏依赖项注入(inject)。缩小 $scope 后不再是 $scope,它们是缩小的变量,如 e 或 a。这对于 AngularJS 来说没有任何意义。要解决此问题,您可以使用 ng-annotate 进行 gulp 和 grunt 以及需要使用 /* @ngInject */

自动依赖注入(inject)的注释函数

通过此链接了解更多详细信息。 AngularJs Minification and Annotation

关于javascript - 缩小 Angular 应用程序后, Angular js ui-route 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46282937/

相关文章:

javascript - 服务器端的 AngularJS 变量

javascript - 在 AJAX 调用时将 jQuery 对象转换为字符串

javascript - AngularJs 谷歌地图中的点击事件

javascript - AngularJS UI 路由器链接到状态之间的 URL 参数的状态

javascript - Angular-UI - 转换到相同状态更新 URL 但后退按钮损坏

java - 使用我的网络应用程序在 Facebook 上分享图像

javascript - 无法更改 Javascript 中的上下文?

javascript - 修改嵌入的 Angular Directive(指令)

angularjs - 没有 ng-repeat 的 Angular 中的替代样式 <ul> 元素

javascript - Angular UI 路由器 - 状态查询字符串参数不起作用