I'm not sure why the change detection wouldn't work here. I've tried a few things, including a setTimeout. I'm using RC5. Basically I want to change the content based off of a parameter in my URL. Should be pretty simple right?
thanks.ts
import { Component } from '@angular/core';
import { Card } from '../../ponents/card/card';
import { ActivatedRoute } from '@angular/router';
@Component({
selector: 'sd-thanks',
styleUrls: ['thanks.css'],
directives: [Card],
templateUrl: 'thanks.html'
})
export class Thanks {
params: any;
ing: any;
constructor(public route: ActivatedRoute) {
this.params = this.route.params.subscribe(
params => {
thising = params['ing'];
console.log(thising); // this consoles the correct true/false value
}
);
}
}
thanks.html
<card>
<div *ngIf="ing" class="card-content">
<span class="card-title">We can't wait to see you!</span>
</div>
<div *ngIf="!ing" class="card-content">
<span class="card-title">We will certainly miss you!</span>
</div>
</card>
I'm not sure why the change detection wouldn't work here. I've tried a few things, including a setTimeout. I'm using RC5. Basically I want to change the content based off of a parameter in my URL. Should be pretty simple right?
thanks.ts
import { Component } from '@angular/core';
import { Card } from '../../ponents/card/card';
import { ActivatedRoute } from '@angular/router';
@Component({
selector: 'sd-thanks',
styleUrls: ['thanks.css'],
directives: [Card],
templateUrl: 'thanks.html'
})
export class Thanks {
params: any;
ing: any;
constructor(public route: ActivatedRoute) {
this.params = this.route.params.subscribe(
params => {
this.ing = params['ing'];
console.log(this.ing); // this consoles the correct true/false value
}
);
}
}
thanks.html
<card>
<div *ngIf="ing" class="card-content">
<span class="card-title">We can't wait to see you!</span>
</div>
<div *ngIf="!ing" class="card-content">
<span class="card-title">We will certainly miss you!</span>
</div>
</card>
Share
Improve this question
asked Sep 2, 2016 at 7:13
jaruesinkjaruesink
1,2032 gold badges14 silver badges24 bronze badges
1 Answer
Reset to default 3Params can only be strings because they e from the URL
If you change it to
this.ing = params['ing'] && params['ing'].toLowerCase() === 'true';
it should work.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744136359a4560076.html
评论列表(0条)