I want to use mat-checkbox in my project for to go in another component. Now the problem is, when I click mat-checkbox this not stay checked, only go in another page.
I tried this code.
Component 1.
html code:
<div class="row col s12">
<div class="input-field col s1">
<p>Sort:</p>
</div>
<div class="input-field col s2">
<mat-checkbox class="example-margin" (click)="getallevents()">Get all events:</mat-checkbox>
</div>
</div>
<hr>
<div ngFor="let item of events">
</div>
Ts Code:
ngOnInit() {
this.events= this.service.getData();
}
public getallevents() {
this.router.navigate(['/main/all_events_acted0/']);
}
Component2:
html code:
<div class="row col s12">
<div class="input-field col s1">
<p>Sort:</p>
</div>
<div class="input-field col s2">
<mat-checkbox class="example-margin" (click)="getallevents0()">Get All events by 0:</mat-checkbox>
</div>
</div>
<hr>
<div ngFor="let item of getalleventsby0">
</div>
Ts code:
ngOnInit() {
this.getalleventsby0= this.service.getData();
}
public getallevents0() {
this.router.navigate(['/main/getallevents0/']);
}
When I click checkbox I want to go in another component, also I want to stay checked this checkbox. Please any idea?
Aucun commentaire:
Enregistrer un commentaire