0

I've upgraded my version of Angular to 1.7.8 and also upgraded angular-ui-router to 1.0.22.

After upgrade my resolved data from the router configuration isn't working (anymore).

Route configuration:

$stateProvider.state('app', {
views: {
    '@' : {
        templateUrl: CONFIG.BasePath + '/article/views/layout.html'
    },
    'article@app': {
        templateUrl: CONFIG.BasePath + '/article/views/index.html',
        controller: 'ArticleController',
        resolve : {
            settings: function() {
                return {
                    someValue: ''
                };
            },
            deps: ['$ocLazyLoad', function($ocLazyLoad) {
                // other code
            }]
        }
    }
}})

Controller:

function MapController ($scope, settings) {
    console.log(settings);
}

MapController.$inject = [
    '$scope',
    'settings'
];

When I try to access it from the resolves object, it works, but this is not the way to go imho...

function MapController ($scope) {
    console.log($scope.myResolves.$state$.views['article@app'].resolve.settings());
}

MapController.$inject = [
    '$scope'
]

1 Answer 1

3

ui-router 1.0 does not support resolve into views:

We no longer process resolve blocks that are declared inside a views.

you need to rewrite it and move resolves out to a resolve block on the state:

Now, move all resolves out to a resolve block on the state:

Read here for more details and examples: ui-router

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.