gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 03:26:53 25 4
gpt4 key购买 nike

您好,我使用 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com