2017-08-14 88 views
0

的一部分。在我的自定義組件:角模板不是組件

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

使用'templateUrl'不'templateURL' – Faisal

回答

2

打字稿工具已經通知你,你在012有錯字

templateURL 

應該

templateUrl