当我只使用1个@Input时(请参见下面的ElementType),一切都很好。 但是,当我添加第二个@Input(验证提示)时,第一个输入可以识别,而第二个则不能。
@Component({
selector: 'sh-workspace-header',
templateUrl: './workspace-header.component.html',
styleUrls: ['./workspace-header.component.scss']
})
export class WorkspaceHeaderComponent implements OnInit {
@Input() ElementType: string;
@Input() ValidationHint: string; <- Not recognized
@Output() HeaderEvent = new EventEmitter<WorkspaceHeaderEvent>();
引用此组件的HTML:
<div class="heading">
<sh-workspace-header [ElementType]="'Project'"
[ValidationHint]="'none'"
(HeaderEvent)="catchHeaderEvent($event)" >
</sh-workspace-header>
</div>
Chrome开发者工具控制台:
答案 0 :(得分:0)
如果要传递字符串。您可以通过删除方括号来传递普通属性而不是属性绑定。
<sh-workspace-header ElementType="'Project'" ValidationHint="'none'" (HeaderEvent)="catchHeaderEvent($event)" >
</sh-workspace-header>