问题
AppSidebarNavItemsComponent.html:33 ERROR TypeError: Cannot read property 'length' of undefined at createUrlTree (router.js:1902) at Router.push../node_modules/@angular/router/fesm5/router.js.Router.createUrlTree (router.js:4220) at AppSidebarNavLinkComponent.push../node_modules/@coreui/angular/fesm5/coreui-angular.js.AppSidebarNavLinkComponent.ngOnInit (coreui-angular.js:1317) at checkAndUpdateDirectiveInline (core.js:22494) at checkAndUpdateNodeInline (core.js:31090) at checkAndUpdateNode (core.js:31052) at debugCheckAndUpdateNode (core.js:31686) at debugCheckDirectivesFn (core.js:31646) at Object.eval [as updateDirectives] (AppSidebarNavItemsComponent.html:33) at Object.debugUpdateDirectives [as updateDirectives] (core.js:31638)
回答1:
I've found that the issue for me was how the navigation items were incorrectly defined.
Make sure that items with no URL are properly marked as either divider: true
or title: true
The problematic element for me was:
{
name: 'HELLO'
}
Changed it to:
{
name: 'HELLO',
title: true
}
No more console error, I can change items all I want without errors.
来源:https://stackoverflow.com/questions/61138035/custom-navigation-for-different-user-using-core-ui-angular-template-but-i-am-get