升级到 angular 1.3 后,angular-ui-router 视图和控制器未加载 [英] angular-ui-router views and controllers are not loading after upgrading to angular 1.3

查看:19
本文介绍了升级到 angular 1.3 后,angular-ui-router 视图和控制器未加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在对 angular 1.3 进行更新后,我无法访问控制器和视图,它们根本无法加载.

after I did the update to angular 1.3 I'm not able to reach the controllers and views, they simply doesn't load.

我根目录中的状态运行良好,这是我的 app.js

the states in my root works perfectly, this is my app.js

$stateProvider.state("root",
    {
        url: '',
        abstract: true,
        views: {
            'footer@': {
                templateUrl: "/partial/footer/footer.html",

            },
            'header@': {
                templateUrl: "/partial/header/header.html",
            }
        }
    }).state('root.home', {
            url: '/index',
            views: {
                'container@': {
                    templateUrl: '/partial/index/index.html',
                    controller: 'IndexCtrl'
                }
            }
        }
    ).state('root.welcome', {
        url: '/index/:status',
        views: {
            'container@': {
                templateUrl: '/partial/index/index.html',
                controller: 'IndexCtrl'
            }
        }
    });

也是我的配置:

$urlRouterProvider.otherwise('index');
$locationProvider.hashPrefix('!');
$locationProvider.html5Mode({ enabled: false });

在执行 stage.go 或仅输入网址后,在这些状态下我无法到达任何路线:

by after doing a stage.go or just by typing the url, I'm not able to reach any route in these states:

$stateProvider.state("candidate",
    {
        url: '',
        abstract: true,
        views: {
            'footer@': {
                templateUrl: "/partial/footer/footer.html"
             },
            'header@': {
                templateUrl: "/user/partial/user.header/user.header.html",
            },
            'sideBar@': {
                templateUrl: '/user/partial/user.sidebar/user.sidebar.html',
                controller: 'SidebarCtrl',
                resolve: {
                    user: 'currentUser'
                }
            },
            'navBar@': {
                templateUrl: '/user/partial/navbar/navbar.html'
            }
        }
    }).state('candidate.dashboard',
    {
        url: '/dashboard',
        views: {
            'container@': {
                templateUrl: '/user/partial/user.dashboard/user.dashboard.html',
                controller: 'DashboardCtrl',
                resolve: {
                    dashboardinfo: function ($resource, tracker) {
                        var resourceGet = $resource('/user/dashboard');
                        var promise = resourceGet.get().$promise;
                        tracker.addPromise(promise);
                        return promise;
                    }
                }
            }
        }
    })

我花了几个小时试图解决这个问题,但没有任何运气,也许这只是我遗漏的一个小细节,欢迎提供任何建议.

I've spent a couple of hours trying to figure this out without any luck, maybe it's just a small detail I'm missing, any advice will be more than welcome.

PS:我使用的是 v0.2.12-pre1

PS: I'm using v0.2.12-pre1

推荐答案

结果是resolve方法失败了,我使用的是angular promise tracker

it turns out that the resolve method was failing, I'm using angular promise tracker

 var resourceGet = $resource('/user/dashboard');
 var promise = resourceGet.get().$promise;
 tracker.addPromise(promise); <-- fails here
 return promise;

似乎资源和承诺发生了重大变化,我的实现可能会被弃用.

it seems like resources and promises have breaking changes and my implementation could be deprecated.

这篇关于升级到 angular 1.3 后,angular-ui-router 视图和控制器未加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆