0
我在我的應用程序上有一條名爲home
的路線,並且上面有一些內容。問題是這個內容沒有被顯示,它只顯示在app.component
的菜單。我覺得我錯過了一些愚蠢的東西,有人能幫助我嗎?這是代碼:路由內容未顯示
這是Home.component:
import {Component} from '@angular/core';
@Component({
moduleId: module.id,
selector: 'home',
templateUrl: `home.component.html`
})
export class HomeComponent{}
App.routing.ts:
import {ModuleWithProviders} from '@angular/core';
import {Routes, RouterModule} from '@angular/router';
import {HomeComponent} from './home.component'
const appRoutes: Routes = [
{
path:'',
redirectTo: '/',
pathMatch: 'full'
},
{
path: 'home',
component: HomeComponent
},
]
export const routing: ModuleWithProviders = RouterModule.forRoot(appRoutes);
app.module.ts:
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import {HomeComponent} from './home.component';
@NgModule({
imports: [ BrowserModule ],
declarations: [ AppComponent, HomeComponent ],
bootstrap: [ AppComponent ]
})
export class AppModule { }
和孤單index.html:
<!DOCTYPE html>
<html>
<head>
<title>Angular QuickStart</title>
<base href="/">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="styles.css">
<link rel="stylesheet" href="css/meu-css.css">
<link type="text/css" rel="stylesheet" href="css/materialize.min.css" media="screen,projection"/>
<!-- Polyfill(s) for older browsers -->
<script src="node_modules/core-js/client/shim.min.js"></script>
<script src="node_modules/zone.js/dist/zone.js"></script>
<script src="node_modules/systemjs/dist/system.src.js"></script>
<script src="systemjs.config.js"></script>
<script>
System.import('main.js').catch(function(err){ console.error(err); });
</script>
</head>
<body>
<base href="/">
<my-app>Loading AppComponent content here ...</my-app>
</body>
</html>