Я создал проект в angular (версия 2.1.0) в visual studio 2017.
Все работает нормально, я получаю сообщение об ошибке, как показано ниже:
EXCEPTION: Uncaught (in promise): Error: Cannot find primary outlet to load 'AppComponent'
Error: Cannot find primary outlet to load 'AppComponent'
Всего 5 ошибок появляются в консоли, но они не проблема в коде во время работы.
app.routes.ts
import { ModuleWithProviders } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { AppComponent } from './app.component';
//import { AboutComponent } from './demo/about.component';
const appRoutes: Routes = [
{
path: 'Home',
children: [
{
path: 'Index',
component: AppComponent
},
//{
// path: 'About',
// component: AboutComponent
//}
]
},
{ path: '**', component: AppComponent }
];
export const routing: ModuleWithProviders = RouterModule.forRoot(appRoutes);
app.component.ts
import { Component, OnInit, ViewContainerRef } from '@angular/core';
// Add the RxJS Observable operators we need in this app.
import './js/ng/rxjs-operators';
@Component({
moduleId: module.id,
selector: 'demo-tag',
templateUrl: './demo/demo-list.html'
})
export class AppComponent {
constructor(private viewContainerRef: ViewContainerRef) {
this.viewContainerRef = viewContainerRef;
}
name = 'First Angular 2 Application';
}
app.component.html
<router-outlet></router-outlet>
demo-list.html (он есть в приложении - demo - demo-list.html)
<div>This is demo list page</div>