javascript - Subscribing to ActivatedRoute Params in Angular 2 does not update view templates -


i'm not sure why change detection wouldn't work here. i've tried few things, including settimeout. i'm using rc5. want change content based off of parameter in url. should pretty simple right?

thanks.ts

import { component } '@angular/core'; import { card } '../../components/card/card'; import { activatedroute } '@angular/router';  @component({   selector: 'sd-thanks',   styleurls: ['thanks.css'],   directives: [card],   templateurl: 'thanks.html' }) export class {   params: any;   coming: any;   constructor(public route: activatedroute) {     this.params = this.route.params.subscribe(       params => {         this.coming = params['coming'];         console.log(this.coming); // consoles correct true/false value       }     );   } } 

thanks.html

<card>   <div *ngif="coming" class="card-content">     <span class="card-title">we can't wait see you!</span>   </div>   <div *ngif="!coming" class="card-content">     <span class="card-title">we miss you!</span>   </div> </card> 

params can strings because come url

if change to

this.coming = params['coming'] && params['coming'].tolowercase() === 'true'; 

it should work.


Comments