docs: Updated router guide content and examples for paramMap
and queryParamMap, tracing, and incidental improvements. closes #16991 and #16259 which it also fixes.
This commit is contained in:

committed by
Matias Niemelä

parent
4268c82898
commit
8d01db4638
@ -15,7 +15,7 @@ describe('HeroDetailComponent - no TestBed', () => {
|
||||
beforeEach((done: any) => {
|
||||
expectedHero = new Hero(42, 'Bubba');
|
||||
activatedRoute = new ActivatedRouteStub();
|
||||
activatedRoute.testParams = { id: expectedHero.id };
|
||||
activatedRoute.testParamMap = { id: expectedHero.id };
|
||||
|
||||
router = jasmine.createSpyObj('router', ['navigate']);
|
||||
|
||||
|
@ -53,7 +53,7 @@ function overrideSetup() {
|
||||
// #enddocregion hds-spy
|
||||
|
||||
// the `id` value is irrelevant because ignored by service stub
|
||||
beforeEach(() => activatedRoute.testParams = { id: 99999 } );
|
||||
beforeEach(() => activatedRoute.testParamMap = { id: 99999 } );
|
||||
|
||||
// #docregion setup-override
|
||||
beforeEach( async(() => {
|
||||
@ -158,7 +158,7 @@ function heroModuleSetup() {
|
||||
|
||||
beforeEach( async(() => {
|
||||
expectedHero = firstHero;
|
||||
activatedRoute.testParams = { id: expectedHero.id };
|
||||
activatedRoute.testParamMap = { id: expectedHero.id };
|
||||
createComponent();
|
||||
}));
|
||||
|
||||
@ -229,7 +229,7 @@ function heroModuleSetup() {
|
||||
// #docregion route-bad-id
|
||||
describe('when navigate to non-existant hero id', () => {
|
||||
beforeEach( async(() => {
|
||||
activatedRoute.testParams = { id: 99999 };
|
||||
activatedRoute.testParamMap = { id: 99999 };
|
||||
createComponent();
|
||||
}));
|
||||
|
||||
@ -279,7 +279,7 @@ function formsModuleSetup() {
|
||||
|
||||
it('should display 1st hero\'s name', fakeAsync(() => {
|
||||
const expectedHero = firstHero;
|
||||
activatedRoute.testParams = { id: expectedHero.id };
|
||||
activatedRoute.testParamMap = { id: expectedHero.id };
|
||||
createComponent().then(() => {
|
||||
expect(page.nameDisplay.textContent).toBe(expectedHero.name);
|
||||
});
|
||||
@ -307,7 +307,7 @@ function sharedModuleSetup() {
|
||||
|
||||
it('should display 1st hero\'s name', fakeAsync(() => {
|
||||
const expectedHero = firstHero;
|
||||
activatedRoute.testParams = { id: expectedHero.id };
|
||||
activatedRoute.testParamMap = { id: expectedHero.id };
|
||||
createComponent().then(() => {
|
||||
expect(page.nameDisplay.textContent).toBe(expectedHero.name);
|
||||
});
|
||||
|
@ -29,7 +29,7 @@ export class HeroDetailComponent implements OnInit {
|
||||
// #docregion ng-on-init
|
||||
ngOnInit(): void {
|
||||
// get hero when `id` param changes
|
||||
this.route.params.subscribe(p => this.getHero(p && p['id']));
|
||||
this.route.paramMap.subscribe(p => this.getHero(p.has('id') && p.get('id')));
|
||||
}
|
||||
// #enddocregion ng-on-init
|
||||
|
||||
|
Reference in New Issue
Block a user