Search code examples
angularjsangularjs-routing

cannot resolve from state ' ' . What configuration did i put wrong?


I am trying to go using ui-sref but it's saying cannot resolve from ''. What did I do wrong in the route configuration. Everything seems correctly configured from my point of view. But i am getting this error.

view

 <li><a ui-sref="container.demurrage.index">Container Management</a></li>

Js

angular.module("app.container",
    [
        "ui.router",
        "ui.select",
        "ui.bootstrap",
    ])
    .config([
        "$stateProvider", function ($stateProvider) {
            $stateProvider.state("container",
                {
                    url: "/container",
                    template: "<div ui-view></div>",
                    abstract: true
                });
            $stateProvider.state("container.demurrage.index",
                {
                    url: "/demurrage",
                    templateUrl: "/container/demurrageindex",
                    controller: "demurrageIndexController",
                    resolve: {

                    }
                });
    

        }
    ])


Solution

  • For someone who has the same issue, I post the solution and it was the naming issue.

    If the parent is container the children should be container.{some name} NOT container.{name}.{name}.

    angular.module("app.container",
        [
            "ui.router",
            "ui.select",
            "ui.bootstrap",
        ])
        .config([
            "$stateProvider", function ($stateProvider) {
                $stateProvider.state("container",
                    {
                        url: "/container",
                        template: "<div ui-view></div>",
                        abstract: true
                    });
                $stateProvider.state("container.demurrageindex",
                    {
                        url: "/demurrage",
                        templateUrl: "/container/demurrageindex",
                        controller: "demurrageIndexController",
                        resolve: {
    
                        }
                    });
        
    
            }
        ])