Hi,
I’ve tried to follow the Angular Documentation, but I can’t seem to pass data to my component type script file.
There is my TS component :
import {Component, Input} from '@angular/core';
import {PollProvider} from "../../providers/poll/poll";
import {NavParams} from "ionic-angular";
@Component({
selector: 'poll-box',
templateUrl: 'poll-box.html',
})
export class PollBoxComponent {
private _poll: any;
public pollData: any;
@Input()
set poll(poll: any) {
this._poll = poll ? poll : null;
this.pollData = poll;
}
get poll(): any {
return this._poll;
}
//@Input() poll: any;
@Input() auth: boolean;
@Input() index: number;
@Input() userId: number;
public responses: any;
constructor(public pollProvider: PollProvider, public navParams: NavParams) {
console.log(this._poll);
console.log(this.poll);
console.log(this.pollData);
console.log(navParams.get('poll'));
}
}
And My Html page where I call the component :
<div class="article-poll">
<poll-box [poll]="poll" [auth]="auth" [userId]="user ? user.id : null" [index]="i" *ngFor="let poll of polls; let i = index"></poll-box>
</div>
All of my console.log return “undefined” but correctly appear in html component. So, what am I doing wrong or what I did not grasp ?
If anybody can help =)
Thanks you a lot !