2
私のページの1つのパラメータ(ハッシュオブジェクト)をコンポーネントに渡そうとしています。Ionic 2のコンポーネントにパラメータを渡す
コンポーネントのビューからオブジェクトにアクセスできます。しかし、私が望むのは、コード(.ts
)から最初に読んでから、ビューに渡すことです。
これは私が直接ビューからノードにアクセスする場合、それは<div *ngFor="let selected of node">
の作品しかし、どのように私は、コンポーネントのコード自体からのコンポーネントに渡されたのparamsにアクセスすることができます私のコード
#main page component
<selected-options [node]="node"></selected-options>
#selected-options component code
import { Component, Input } from '@angular/core';
import { NavController, NavParams } from 'ionic-angular';
@Component({
selector: 'selected-options',
templateUrl: 'build/components/selected-options/selected-options.html',
inputs: ['node']
})
export class SelectedOptions {
@Input() node: any;
private selectedNodes: any;
constructor(public ryvuss: Ryvuss, public nav: NavController, public navParams: NavParams) {
// I want to read the node object in here
this.node = navParams.get('node');
this.selectedNodes = //dosomething with node
}
}
#selected-options component html view
<div *ngFor="let selected of selectedNodes">
//loop
</div>
のですか? Angular2 docsから
私を助けるため再びおかげで多くのことを、私は」私の次の問題に固執しています。あなたが見ていて気にしないと、自由な時間を過ごすと、http:// stackov erflow.com/questions/38986839/access-a-provider-class-from-my-components-input-method-ionic2-angular2、もう一度お返事ありがとうございます – sameera207
私は助けてくれるとうれしいです:)確かに、私は見ていきますそれで – sebaferreras