【发布时间】:2017-04-17 12:32:46
【问题描述】:
我是 Angular2 的初学者,我创建了一个模态对话框,这是我的 HTML 文件。 index.html 文件:-
<button type="button" class="btn btn-default" (click)="modal.open()">Open</button>
<modal #modal>
<modal-header [show-close]="true">
<h4 class="modal-title">I'm a modal!</h4>
</modal-header>
<modal-body>
Here i want to call show() method from .ts file.
</modal-body>
<modal-footer [show-default-buttons]="true"></modal-footer>
</modal>
点击打开按钮后,我想调用 .ts 文件中的show(){....}
我想在<modal-boady></modal-body>标签内显示。
这是我的 hello.component.ts 文件:-
import {Component, View} from "angular2/core";
@Component({
selector: 'my-app',
templateUrl: './index.html'
})
export class HeapMemoryGraphComponent implements OnInit {
constructor(){}
ngOnInit() {
this.show();
}
show(){
console.log("=====show()=======");
}
}
我怎么能这样做?请指导我。
谢谢。
【问题讨论】:
-
你能把剩下的相关代码贴出来吗?
-
嘿danimal,我更新了我的问题。请问你能看到这个吗?