大佬教程收集整理的这篇文章主要介绍了未处理的Promise rejection:无法找到加载组件Angular2的主要插座,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
Unhandled Promise rejection: CAnnot find priMary outlet to load 'HomeComponent' ; Zone: angular ; Task: Promise.then ; Value: Error: CAnnot find priMary outlet to load 'HomeComponent'
我的应用组件代码:
@Component({ modulEID: module.id,SELEctor: 'sd-app',viewProviders: [NameListservice,http_PROVIDERS],templateUrl: 'app.component.html',directives: [ROUTER_DIRECTIVES,NavbarComponent,ToolbarComponent] }) export class AppComponent { constructor() { console.log('Environment config',Config); } }
app.component.HTML代码:
<sd-navbar><router-outlet></router-outlet></sd-navbar>
应用路由配置:
const routes: RouterConfig = [ { path: 'login',component: LoginComponent,canActivate: [UnauthenticatedGuard] },...HomeRoutes,]; export const APP_ROUTER_PROVIDERS = [ provideRouter(routes),UnauthenticatedGuard,HomeComponentGuard ];
HomeRoutes代码:
export const HomeRoutes = [ { path: '',component: HomeComponent,canActivate: [HomeComponentGuard],children: [ { path: '',component: HomeComponent },{ path: 'home',{ path: 'about',component: AboutComponent } ] },];
Home.Component代码:
import { Component } from '@angular/core'; import { ROUTER_DIRECTIVES } from '@angular/router'; import { NameListservice } from '../shared/index'; @Component({ modulEID: module.id,SELEctor: 'wrapper',templateUrl: 'home.component.html',styleUrls: ['home.component.css'],directives: [ROUTER_DIRECTIVES] }) export class HomeComponent { newName: String; constructor(public nameListservice: NameListservicE) { console.log("nameList: " + JSON.Stringify(nameListservice.get())); } addName(): Boolean { this.nameListservice.add(this.newName); this.newName = ''; return false; } }
每位家长必须拥有< router-outlet>< / router-outlet>.以下是对github https://github.com/angular/angular/issues/10686的回复.
以上是大佬教程为你收集整理的未处理的Promise rejection:无法找到加载组件Angular2的主要插座全部内容,希望文章能够帮你解决未处理的Promise rejection:无法找到加载组件Angular2的主要插座所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。