【发布时间】:2018-11-27 06:52:32
【问题描述】:
我有一个只有一个按钮的 Angular 应用程序。
点击按钮后,我将能够打开一个弹出窗口
index-component.html(登陆页面)
<button type="button" class="btn btn-primary" (click)=warning.show()>
</button>
<app-modal #warning>
</app-modal>
index-component.ts
@Component({
selector: 'app-modal',
templateUrl: './model-component.html',
styleUrls: ['./model-component.css']
})
export class IndexComponent implements OnInit {
public show(): void {
this.visible = true;
setTimeout(() => this.visibleAnimate = true, 100);
}
}
model-component.html(弹出组件)
<div class="modal-dialog modal-sm" role="document">
<div class="modal-content">
Some data for popup here..........
</div>
</div>
上面的打开弹窗的执行是通过线路发生的
(click)=warning.show()
这是完美的工作。
现在我需要将此调用移至 TS 文件。
所以,在 index-component.ts 中我需要调用 warning.show()
但是,我无法在 TS 文件中获取 #warning 的实例。
我将如何实现这一目标?
【问题讨论】:
标签: angular typescript