简体   繁体   中英

Declare variable in custom template in Angular 2

How can I declare variable that isn't coming from parent component? In this example rowData comes from p-column but I need to declare another variable.

<p-column *ngFor="let h of header">
    <template let-ms="rowData" pTemplate="body" let-m="getMetricByName(ms.metrics, h)">
                {{m.name}} //for example
    </template>
</p-column>

There is currently no way to declare variables in the template.

See also angular's ng-init alternative in Angular 2

This issue seems related https://github.com/angular/angular/issues/15020

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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