也许我的想法完全错了。但我想做的是在组件中调用模板中定义的变量的值。
<button (click)="download()">...</button>
<ng-container *ngIf="objectlist | filterSort: sortColumnService.sortTerm() as filteredSkaterlist">
...
</ng-container>
有什么干净的方法可以访问组件函数中的filteredSkaterlist
吗?发送filteredSkaterlist
作为例如click()
的参数是不可选择的,因为按钮超出了范围。
@Component({...})
export class MyComponent {
...
download() {
// access value of filteredSkaterlist
}
}
你能试试这种方法吗。
<ng-container *ngIf="objectList()">
...
</ng-container>
我已经用*ngIf的结构指令定义了objectList((方法。我们可以在组件类中定义objectList((方法,并根据条件返回true或false。
@Component({...})
export class MyComponent {
objectList() : boolean {
// access value class objects and return true false value
}
}