ionic2 - Acess data from Start Page using Ionic 2 + Angular 2 -


edit

i have web service rest provides menu this:

{   "items": [     {       "content-type": "one",       "title": "title1",       "url": "url1";     },     {       "content-type": "two",       "title": "title2",       "url": "url2"     }   ] } 

in start page menu, , gives dynamic content, provides different pages.

@component({     providers: [apiclient],     templateurl: 'build/app.html',     selector: 'my-app' }) class myapp {     @viewchild(nav) nav: nav;      rootpage: = somecomponent;      @input() url: string;       pages: array<{ title: string, component: any, url: string }>;      constructor(public platform: platform, private _apiclient: apiclient) {          this.initializeapp();         this._apiclient.get("http://localhost:8080/myapp/context/menu",             'menu',             null,             (data) => this.handlesuccessgetmenu(data),             null);     }      initializeapp() {         this.platform.ready().then(() => {             // okay, platform ready , our plugins available.             // here can higher level native things might need.             statusbar.styledefault();         });     }      openpage(page) {         // reset content nav have page         // wouldn't want button show in scenario         this.nav.setroot(page.component);     }        handlesuccessgetmenu(data) {           if ("" != data.items) {             this.pages = [];             (var item of data.items) {                  if (item['content-type'] === "one" || item['content-type'] === "two") {                     this.pages.push({ title: item['title'], component: dynamiccomponent, , url: item['url'] });                     this.url = item['url'];                 }              }         }     }  } ionicbootstrap(myapp); 

i want access url on component don´t know how accomplish that.

@component({   providers: [apiclient],   templateurl: './build/components/dynamic.html' }) export class dynamiccomponent {  //how can acess url  private dynamicurl=myapp.url;    //construtor   constructor(private _apiclient: apiclient, public navparams: navparams) {          **it´s possible way url current page?**    console.log(navctrl.get('url'));    } } 

app component

@component({   selector: 'my-app',   template: `<h1>my first angular 2 app</h1>             <child [url]="link"></child>` }) export class appcomponent implements oninit {    link: string = "hello";    ngoninit(): void {    };  } 

child component

@component({     selector: 'child',     template: `       {{ url }}     ` }) export class childcomponent implements oninit {     @input() url;      constructor() {     }      ngoninit(): void {       console.log(this.url);     }; } 

see plunker example on how access url parent component. i'm not sure if applies ionic if it's angular 2 should same process.

i hope looking for, based on understanding of question.


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -