Search code examples
angularjsangular-ui-routerandroid-contentresolver

UI-route nested views and resolve not working


I have a problem with resolve and my nested view is not loading because ot that. I don't see where is the problem. This was working with ng-route.

Here is my situation. We should see "View3" text bellow other tow. If you remove the resolve it will work.

[http://plnkr.co/edit/p483wWVSp30LGiQMuk1r?p=preview][1]

[1]: http://plnkr.co/edit/p483wWVSp30LGiQMuk1r?p=preview

Solution

  • Here is my State with Resolve. The problem is that i used $route as parameter. $route is averrable for ng-route module.

    .state('test.subs.quest', {
      url: '/:bob',
      views: {
        'quest@test': {
          template: "View3",
          controller: function($stateParams) {
            console.log($stateParams);
          }
        },
      },
      resolve: {
        Questions: function(Questionnaire, $route) {
          console.log('any body here  ?');
          return Questionnaire.Get($route.current.params.slug);
        }
      }
    
    });
    

    and it should be like this:

     .state('categories.category.questionnaire', {
        url: '/:slug',
        views:{
            "main@":{
                template: '<div compilehtml="html"></div>',
                controller: 'QuestionnaireController',
            }
        },
        resolve: {
            Questions: function(Questionnaire, $stateParams ) {
                return Questionnaire.Get($stateParams.slug); 
            }
        }
    })