Angular 2 - 'imports' does not exist in type 'Co
Angular 2 - 'imports' does not exist in type 'ComponentMetadataType'
我有一个Angular 2应用,现在我想使用双向绑定。当我尝试分配imports: [FormsModule]
时,发生了一个错误:
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]
})
不能在组件中使用imports
。你应该在ngModule
装饰器中导入所有必需的依赖项。
请查看Angular JS文档中的以下示例:
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 { }
相关文章:
- Node.js's Buffer.writeFloatBE in Javascript
- Setting default onclick behavior for <img> tag in gene
- Lucene Search in Alfresco
- grep in JQuery to C#
- write HTML in JavaScript
- jQuery setTimeOut: in for-loop
- SetTimeout and clearTimeout in Javascript
- lightbox in html 5 and javascript
- HTMLInputElement in IE7
- Mongodb$in以与数组中相同的顺序获取结果
- element.dataset in Internet Explorer
- jQuery parent() in table
- Instagram oauth flow in angularjs
- In循环的In运算符前后
- 如何使用for in循环在javascript中显示对象中的对象
- Jquery change onchange in onload
- 重构 jQuery in JS 问题
- strongloop script.js run find in before delete方法:如何同步运行异步方法
- TicTacToe minimax AI in Javascript
- Angular 2 - 'imports' does not exist in type 'Co