【发布时间】:2019-10-27 14:48:03
【问题描述】:
我想使用 ngTemplate 实现一些东西,我正在关注 this example。
添加@input时出现我面临的问题:
import { Component, OnInit, TemplateRef } from '@angular/core';
@Component({
selector: 'app-my',
templateUrl: './my.component.html',
styleUrls: ['./my.component.css']
})
export class MyComponent implements OnInit {
...
@Input() headingTemplate: TemplateRef<any>;
}
保存后会在控制台显示此错误消息:
my.component.ts:13 Uncaught ReferenceError: Input is not defined 在 Module../src/app/my/my.component.ts (my.component.ts:13)
为什么会发生这种情况以及如何解决?我什至在their github 项目上找到了该文件,但仍然不知道。可能是因为我使用的是 Angular 8 造成的问题?
【问题讨论】:
-
请接受 Sajeetharan 的回答,因为他在我之前几秒钟发布了相同的答案
-
我不明白为什么这被认为是题外话。我来寻找相同问题的答案
标签: javascript angular input ng-template