import { BehaviorSubject } from "rxjs/BehaviorSubject" ; import { Observable } from "rxjs/Observable" ; import { Injectable } from '@angular/core' ; @ Injectable ( ) export class StateService { private stateSubject : BehaviorSubject < string > = new BehaviorSubject ( '' ) ; set searchCriteria ( value ) { this . stateSubject . next ( value ) ; } getState ( ) { return this . stateSubject . asObservable ( ) ; } }