0

PLNKR: http://plnkr.co/edit/Or4JTiUrPOJUoW78c8Xd

Hey guys, I'm struggling with an issue that i was able to simplify down to the following sample:

var myapp = angular.module('myapp', ["ui.router"])
myapp.config(function($stateProvider, $urlRouterProvider){
    $urlRouterProvider.otherwise("/items/123");

    $stateProvider
        .state('dashboard', {
            url: "/items/:itemId",
            templateUrl: 'dashboard.html',
            controller: function($scope, $stateParams){
              $scope.itemId = $stateParams.itemId;
            },
            resolve: {
                itemParam: ['$stateParams', function($stateParams){
                    return $stateParams.itemId;
                }]
            }
        })
        .state('dashboard.history', {
            parent: 'dashboard',
            url: "/history",
            templateUrl: 'dashboard.history.html',
            controller: function($scope, itemParam){
              $scope.itemId = itemParam.itemId;
            }
        });
})

dashboard.html

<h1>Dashboard for item {{itemId}}</h1>
<a ui-sref="dashboard.history({itemId: 123})">History</a>

dashboard.history.html

<h1>Dashboard History for item {{itemId}}</h1>

The problem is history controller isn't being called and I'm getting no errors. Can anybody explain to me what's up?

Thanks in advance!

1 Answer 1

1

This is because you don't have a <ui-view> directive inside your parent state:

FORKED DEMO

dashboard.html

<h1>Dashboard for item {{itemId}}</h1>
<a ui-sref="dashboard.history({itemId: 123})">History</a>
<ui-view></ui-view>
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.