Javascript 使用routerOutlet的Angular2
我正在努力扩展angular2应用程序,它是用yo fountain webapp生成的。我遇到的问题是,我无法运行以在内部渲染模板 我是angular2的新手,我刚刚开始阅读文档和一些示例应用程序。我注意到有机会将不同的组件渲染到主应用程序模板文件中,这正是我要寻找的 然而,由于某种原因,我无法让它工作 我在main.html中有这段代码Javascript 使用routerOutlet的Angular2,javascript,angular,ecmascript-6,components,Javascript,Angular,Ecmascript 6,Components,我正在努力扩展angular2应用程序,它是用yo fountain webapp生成的。我遇到的问题是,我无法运行以在内部渲染模板 我是angular2的新手,我刚刚开始阅读文档和一些示例应用程序。我注意到有机会将不同的组件渲染到主应用程序模板文件中,这正是我要寻找的 然而,由于某种原因,我无法让它工作 我在main.html中有这段代码 `<div class="main-container"> <fountain-header></fountain-hea
`<div class="main-container">
<fountain-header></fountain-header>
<main class="main">
<fountain-title></fountain-title>
<fountain-techs></fountain-techs>
<some-selector></some-selector>
<!-- Router Outlet -->
<router-outlet></router-outlet>
</main>
<div class="col-md-6 col-md-6-offset4">
<fountain-footer></fountain-footer>
</div>
</div>`
routes.js
import {Component} from '@angular/core';
import {RouterModule} from '@angular/router';
import {MainComponent} from './main';
import {SomeComponent} from './some';
@Component({
selector: 'fountain-root',
template: '<router-outlet></router-outlet>'
})
export class RootComponent {}
export const routes = [
{
path: '',
component: MainComponent
},
{
path: 'some',
component: SomeComponent
}
];
export const routing = RouterModule.forRoot(routes);
import {Component} from '@angular/core';
import {RouterModule} from '@angular/router';
import {MainComponent} from './main';
import {SomeComponent} from './some';
@Component({
selector: 'fountain-root',
template: '<router-outlet></router-outlet>'
})
export class RootComponent {}
export const routes = [
{
path: '',
component: MainComponent
},
{
path: 'some',
component: SomeComponent
}
];
export const routing = RouterModule.forRoot(routes);
import {Component} from "@angular/core";
import {ROUTER_DIRECTIVES} from '@angular/router';
@Component({
selector: 'some-selector',
template: require('./some.html'),
directives: [ROUTER_DIRECTIVES]
})
export class SomeComponent {
constructor() {
this.title = "Holla molaa!";
this.description = 'this is the description';
}
}