Angular 2 md-input 占位符未随 ngmodel 向上移动

Angular 2 md-input placeholder not moving up with ngmodel

我正在使用 Angular Material 设置输入样式。通常当输入中有值时,占位符应该向上移动;但是当我使用 ngModel 绑定它时并没有发生。但是,如果我单击输入,占位符会向上移动。

这是我的部分代码:

<input mdInput type="text"
       [(ngModel)]="answer.text"
       placeholder="Answer {{i + 1}}"
       [focus]="focus"
       (ngModelChange)="keyPress.emit($event)"
       (keyup.enter)="onEnter.emit()">

我找到了问题的答案: 我在我的组件中使用了 changeDetection: ChangeDetectionStrategy.OnPush。我在 ngOnInit() 函数上使用了 cd.markForcheck(),但我不得不将它移动到 ngAfterViewInit 上,后者在 @Input 数据(放置在我的答案 var 上)被注入我的组件后执行。