ncuillery / angular-breadcrumb

Generate a breadcrumb from ui-router's states
http://ncuillery.github.io/angular-breadcrumb/
MIT License
786 stars 183 forks source link

Cannot read property 'abstract' of null #81

Open gimox opened 9 years ago

gimox commented 9 years ago

i receive this error when settings nested view:

.state('dashboard', {
        url          : '/dashboard',
        templateUrl  : 'app/project/tmpl/dashboard.tmpl.html',
        abstract: true,
        ncyBreadcrumb: {
          label: 'Dashboard'
        }
      })

      .state('dashboard.home', {
        url : '',
        templateUrl: 'app/project/tmpl/dashboard.home.tmpl.html',
        ncyBreadcrumb: {
          label:'test'
        }
      });

if add <div ncy-breadcrumb></div> in dashboard.home.tmpl.html i receive this error:

TypeError: Cannot read property 'abstract' of null
    at $get.$$addStateInChain (http://localhost:3000/bower_components/angular-breadcrumb/release/angular-breadcrumb.js:68:22)
    at Object.$get.getStatesChain (http://localhost:3000/bower_components/angular-breadcrumb/release/angular-breadcrumb.js:126:21)
    at link.post.renderBreadcrumb (http://localhost:3000/bower_components/angular-breadcrumb/release/angular-breadcrumb.js:205:47)
    at postLink (http://localhost:3000/bower_components/angular-breadcrumb/release/angular-breadcrumb.js:223:17)
    at http://localhost:3000/bower_components/angular/angular.js:8252:44
    at invokeLinkFn (http://localhost:3000/bower_components/angular/angular.js:8258:9)
    at nodeLinkFn (http://localhost:3000/bower_components/angular/angular.js:7768:11)
    at compositeLinkFn (http://localhost:3000/bower_components/angular/angular.js:7117:13)
    at publicLinkFn (http://localhost:3000/bower_components/angular/angular.js:6996:30)
    at compile (http://localhost:3000/bower_components/angular-ui-router/release/angular-ui-router.js:3905:9) <ol class="breadcrumb ng-scope ng-isolate-scope" ncy-breadcrumb="">angular.js:11655 (anonymous function)angular.js:8596 $getangular.js:8260 invokeLinkFn
..

the break point is relative to code:

 conf = $state.get(ref.state);
            if((!conf.abstract || $$options.includeAbstract) && !(conf.ncyBreadcrumb && conf.ncyBreadcrumb.skip)) {
                if(ref.paramExpr) {
                    parentParams = $lastViewScope.$eval(ref.paramExpr);
                }

                conf.ncyBreadcrumbLink = $state.href(ref.state, parentParams || $stateParams || {});
                chain.unshift(conf);
            }

i have try different config but same error...

help!

ncuillery commented 9 years ago

Nothing seems wrong in your config...

Please can you provide the versions of:

It could be helpful if you can reproduce the bug in a plunker too. You can fork this one

gimox commented 9 years ago

"angular": v1.3.15 "angular-breadcrumb": v0.3.3 "angular-ui-router": v0.2.13

thanks

tomasz-galazka commented 9 years ago

I came across the same error "Cannot read property 'abstract' of null" Did you fix it?

gimox commented 9 years ago

no! i can not use the breadcrum until fix it!

tlode commented 9 years ago

Could it be that this is just a configuration problem? I've had copied this example from the API Reference

$breadcrumbProvider.setOptions({
      prefixStateName: 'home',
      template: 'bootstrap2'
});

without having the home state. Changing this to some known state has helped fix the problem.

ncuillery commented 9 years ago

@gimox @tomasz-galazka Did you configure the breadcrumbProvider and define an non-existing or abstract state name in the key prefixStateName ?

It could happen if you have copied-pasted the example from the API reference, as @tlode suggested.

gimox commented 9 years ago

try with default config and check existing state. no work.