ui-router解析promise刷新页面

时间:2014-11-24 08:19:39

标签: angularjs promise angular-ui-router

你可以帮我解决同样的问题Angular UI Router, route resolve breaking refresh button

我有工厂:

factory('AppearanceService', function ($resource, $rootScope) {
        return $resource($rootScope.urlAppearanceBackend+'/api/v1/appearance', {}, {
            'query': {method: 'GET', isArray: false},
            'update': {method:'PUT'}
        });
})

路线:

.state('settings', {
                url: '/settings',
                views: {
                    header: {
                        templateUrl: 'views/header.html',
                        controller: 'IntegrationCtrl'
                    },
                    content: {
                        templateUrl: 'views/settings.html',
                        controller: 'SettingsCtrl'
                    },
                    footer: {
                        templateUrl: 'views/footer.html'
                    }
                },
                resolve: {
                    'MySettings':function(AppearanceService, $rootScope) {
                        $rootScope.currentSettingsForm = AppearanceService.query();
                        return $rootScope.currentSettingsForm.$promise;
                    }
                }
            })

控制器:

angular.module('app').controller('SettingsCtrl', function ($scope, MySettings) {    
    $scope.settings = MySettings;
});

当我正常去ui-href时,但是用浏览器按钮重新加载页面 - 错误:

> GET http://localhost:8080/undefined/api/v1/appearance 404 (Not Found)
> app.js:221 Object {data: "Not found↵", status: 404, headers: function,
> config: Object, statusText: "Not Found"}

0 个答案:

没有答案