2016-08-19 6 views
1

私はAngular 2アプリケーションを持っていますが、今は双方向バインディングを使用したいと思います。私はimports: [FormsModule]を割り当てるしようとすると、エラーが発生した起こった。Angular 2 - 'imports'が 'ComponentMetadataType'タイプに存在しません

Argument of type '{ imports: typeof F...' is not assignable to parameter of type 'ComponentMetadataType'. 
Object literal may only specify known properties, and 'imports' does not exist in type 'ComponentMetadataType'. 

をここではコードです:

import {Component, OnInit} from '@angular/core'; 
import {TodoService} from '../todo.service' 
import {FormsModule} from '@angular/forms' 

@Component({ 
    moduleId: module.id, 
    selector: 'app-todos', 
    templateUrl: 'todos.component.html', 
    styleUrls: ['todos.component.css'], 
    imports: [FormsModule] 
}) 

答えて

2

あなたはコンポーネントでimportsを使用することはできません。デコレータngModuleに必要なすべての依存関係をインポートする必要があります。

次の例を見てはAngular JS documentationを形成していてください:

import { NgModule }  from '@angular/core'; 
import { FormsModule } from '@angular/forms'; 
import { AppComponent } from './app.component'; 

@NgModule({ 
    imports: [ 
    FormsModule 
    ], 
    declarations: [ 
    AppComponent 
    ], 
    bootstrap: [ AppComponent ] 
}) 

export class AppModule { } 
関連する問題