在我的自定义组件中:
import { Component } from '@angular/core';
@Component({
selector: 'app-server',
templateURL: './server.component.html'
})
export class ServerComponent{
}
app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms'; //<-- FormsModule import
import { AppComponent } from './app.component';
import { ServerComponent } from './server/server.component'; //Extension (ts) added by web pack
@NgModule({
declarations: [
AppComponent,
ServerComponent
],
imports: [
BrowserModule,
FormsModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
错误:
/src/app/server/server.component.ts (5,2): Argument of type '{ selector: string; templateURL: string; }' is not assignable to parameter of type 'Component'.
Object literal may only specify known properties, and 'templateURL' does not exist in type 'Component'.
答案 0 :(得分:2)
打字稿工具已经告诉你,你在templateURL
templateURL
应该是
templateUrl