Last active
February 20, 2018 11:08
-
-
Save vedrax-admin/9a43224fcda300d7f81b6bc9f38184d2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Injectable} from '@angular/core'; | |
import {BehaviorSubject} from 'rxjs/BehaviorSubject'; | |
import {convertToParamMap, ParamMap} from '@angular/router'; | |
@Injectable() | |
export class ActivatedRouteStub { | |
//Observable that contains a map of the parameters | |
private subjectParamMap = new BehaviorSubject(convertToParamMap(this.testParamMap)); | |
paramMap = this.subjectParamMap.asObservable(); | |
private _testParamMap: ParamMap; | |
get testParamMap() { | |
return this._testParamMap; | |
} | |
set testParamMap(params: {}) { | |
this._testParamMap = convertToParamMap(params); | |
this.subjectParamMap.next(this._testParamMap); | |
} | |
//Observable that contains a map of the query parameters | |
private subjectQueryParamMap = new BehaviorSubject(convertToParamMap(this.testParamMap)); | |
queryParamMap = this.subjectQueryParamMap.asObservable(); | |
private _testQueryParamMap: ParamMap; | |
get testQueryParamMap() { | |
return this._testQueryParamMap; | |
} | |
set testQueryParamMap(params: {}) { | |
this._testQueryParamMap = convertToParamMap(params); | |
this.subjectQueryParamMap.next(this._testQueryParamMap); | |
} | |
get snapshot() { | |
return { | |
paramMap: this.testParamMap, | |
queryParamMap: this.testQueryParamMap | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment