仅当重新访问状态时,angular + ui-router +指令才会触发两次

时间:2016-03-02 19:33:56

标签: angularjs angular-ui-router

任何人都可以帮我解决这个错误吗?

当我导航到使用该指令的状态时,链接会触发一次。

当我离开另一个状态并重新访问相同状态并且链接触发两次时。

我已经完成了典型的故障排除步骤。 IE,关闭指令元素,ng-if / ng-show等

该指令不使用ng-ifng-show

角度1.5.0,ui-router 0.2.18

提前感谢。

我的路线配置:

.state('map', {
            url: '/map/:searchId/{showSearch:bool}/:enableWizard',
            templateUrl: 'app/main/map/map.html',
            controller: 'mapController',
            controllerAs: 'mapCtrl',
            resolve: {
                'google-map': (uiGmapGoogleMapApi: any) => {
                    return uiGmapGoogleMapApi;
                }
            },
            params: {
                locateOnInit: null,
                searchId: null,
                showSearch: null,
                callback: null
            },
            data: {
                backButton: false
            }
        })

1 个答案:

答案 0 :(得分:0)

我认为您在配置中为您的州分配控制器,并在您的html代码中使用ng-controller。这可能是链接触发两次的原因。在你的html中删除ng-controller。试试这个,如果它不起作用,请提供小提琴或编码器

相关问题