TypeError:(void 0)在关闭模式时不是函数

问题描述 投票:0回答:1

我正在使用AngularJS,并将其与webpack捆绑在一起。为了处理我的状态,我使用了ui-router。我已经更改了应用程序的结构,因此状态作为模式加载。当我关闭状态(模态)时,它不断出现错误消息:

TypeError:(void 0)不是一个函数

我在网上搜索过,还有其他人,但似乎没有一个能给出为什么的确切答案。如果我将功能更改为console.log消息,则不会,但不会导致该错误。当我从模式状态转到任何其他状态时,引起该问题的原因。我一直在关注这篇文章https://www.sitepoint.com/creating-stateful-modals-angularjs-angular-ui-router/。我将为代码提供状态结构和用于关闭模态的函数。

$stateProvider
.state('portfolio', {
    url: '/portfolio',
    templateUrl: 'app/templates/portfolio/portfolio.tpl.htm',
    controller: 'portfolioCtrl',
})
.state('portfolio.modal', {
    abstract: true,
    views: {
        "modal": {
            templateUrl: "app/templates/patent/modal.html"
        }
    },
    onEnter: ["$state", function($state) {

        $(document).on("click", ".modal-backdrop, .modal-holder", function() {

            $state.go("portfolio");
        });

    }]

})
.state('portfolio.modal.patent', {
    url: '/:patentId',
        views:{
            "": {
                templateUrl: 'app/templates/patent/case-overview.tpl.htm',
                controller: 'caseOverviewCtrl',
                controllerAs: '$ctrl',

            },
            "[email protected]": {
                templateUrl: 'app/templates/patent/patent-details.tpl.htm',
                controller: 'patentDetailsCtrl',
                controllerAs: '$ctrl'      
            },
      }
 }

问题

为什么关闭模式时会显示错误TypeError: (void 0) is not a function(在关闭时导航至其他状态)?

javascript angularjs angular-ui-router
1个回答
0
投票

最近我遇到了同样的错误,困扰我的原因是我将ts.config中的模块prop从'system'更改为'amd'。

https://www.typescriptlang.org/docs/handbook/modules.html

希望这会有所帮助。

Ps。我只是将其作为评论而非完整的答案,但我没有足够的声誉!

© www.soinside.com 2019 - 2024. All rights reserved.