我正在开发第一个Angular 2应用程序并具有以下代码
AppModule.ts代码
class userComment(models.Model):
client = models.ForeignKey(User, related_name="client")
worker = models.ForeignKey(User, blank=True, null=True, related_name="worker")
sent_at = models.DateTimeField(auto_now_add=True)
comment = models.TextField(max_length=255, null=True)
def __str__(self):
return str(self.client)
AppComponent.ts 代码
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import {RouterModule} from '@angular/router';
import { AppComponent } from './app.component';
import { MenuComponent} from './home/menu/menu.component';
import { FooterComponent} from './home/footer/footer.component';
import { AboutComponent} from './personalDetails/about/about.component';
@NgModule({
imports: [
BrowserModule,
RouterModule.forRoot([
{path: '' , component : AboutComponent},
{path: 'about' , component : AboutComponent}
])
],
declarations: [
AppComponent,
MenuComponent,
FooterComponent,
AboutComponent,
],
bootstrap: [ AppComponent ]
})
export class AppModule { }
答案 0 :(得分:2)
修复很简单,我忘了在index.html中添加基础href标记,
import { Component } from '@angular/core';
@Component({
selector: 'app',
template: `
<menu></menu>
<router-outlet></router-outlet>
<footer></footer>
`
})
export class AppComponent { }
当我研究为什么我们应该默认添加基本href,而在angular1中则不是这样。我找到了以下