简体   繁体   English

如何在单击按钮时调用angular 1.5组件

[英]how to call angular 1.5 component on button click

As i am a newbie in Typescript i am fail to get answer that how to call my angular component "summaryReport "on button click, here is my demo code.let say i have a button that has to call my component on openPdf() click, 由于我是Typescript的新手,因此我无法得到关于如何在单击按钮时调用我的角度组件“ summaryReport”的答案,这是我的演示代码。请说我有一个按钮,必须在openPdf()单击时调用我的组件,

<md-button ng-click="$ctrl.openPdf()">Summary Report</md-button>

My Component code is,

namespace mitchell.audit.estimate {
export class SummaryReportComponent {
    static ngComponentName = 'summaryReport';
}
angular.module(ngModuleName)
    .component(SummaryReportComponent.ngComponentName, {
        bindings: {
            estimateId: '@',
        },
        templateUrl: 'src/app/estimate/pdfReport/pdfSummary-report.component.html',
        controller: PdfSummaryReportController
    });

} and I want to call My Component template, },我想调用“我的组件”模板,

<summary-report flex layout="column" estimate-id="$ctrl.estimateId" style="display:none;"></summary-report>

I also tried calling this component template by putting "" in a HTML file which will be load on button click but this is also not working. 我还尝试通过在HTML文件中放入“”来调用此组件模板,该文件将在单击按钮时加载,但这也不起作用。 Please help me out to find the proper way or solution to click my component template on button click. 请帮助我找到在单击按钮时单击我的组件模板的正确方法或解决方案。 Thanks Manisha 谢谢Manisha

您可以使用$ compile加载组件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM