angular
6 years, 2 months ago
//service.ts
import { Injectable } from '@angular/core';
import { BehaviorSubject } from 'rxjs'
@Injectable({
providedIn: 'root'
})
export class multiSelectService {
constructor() { }
private filterType=new BehaviorSubject<boolean>(null);
filterObservable= this.filterType.asObservable();
setfilterType(type:boolean){
this.filterType.next(type);
}}
//To get values from observable, first initialise service variable.
private serviceVar:multiSelectService;
//Then, subscribe to filterObservable to get value in filtertype.
this.multiSelectDialogService.filterObservable.subscribe(data=>{
this.filterType=data;
this.dialogFilterType=data;
this.diplayData()
});
//To set value to filterType
this.serviceVar.setfilterType(true);
0 Comments
Please Login to Comment Here