Maybe I'm thinking in the completely wrong direction. But what I would like to do is call the value of a variable, which was defined in the template, in the component.
<button (click)="download()">...</button>
<ng-container *ngIf="objectlist | filterSort: sortColumnService.sortTerm() as filteredSkaterlist">
...
</ng-container>
Is there any clean way to access filteredSkaterlist
in a function of the component? To send the filteredSkaterlist
as argument of eg the click()
is no option because the button is out of scope.
@Component({...})
export class MyComponent {
...
download() {
// access value of filteredSkaterlist
}
}
Can you please try this way.
<ng-container *ngIf="objectList()">
...
</ng-container>
I've defined objectList() method with structural directive of *ngIf. We can define objectList() method in component class and return true or false depend on the condition.
@Component({...})
export class MyComponent {
objectList() : boolean {
// access value class objects and return true false value
}
}
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.