Ionic2 Study Notes (6): NAVIGATION

Source: Internet
Author: User

GreyOriginal address: http://www.cnblogs.com/greyzeng/p/5551535.html

?

??

? It is convenient to create a page in Ionic2, and it is convenient to switch between pages, we are implementing the following requirements:

Create a button on the main page, click the button, jump to a new page, during the jump, we can also pass the data between the pages.

    • Enter the project directory: CD myfirstapp
    • Create a new page:

      ionic g page secondpage

      will @import ". /pages/second-page/second-page.scss "; add to App\themes\app.core.scss

    • on the main page app\pages\home\ Add a button to the home.html and add the corresponding Click event handler function to this button openmodal ()

    • Span style= "font-family: Microsoft Jas Black" in App\pages\home\home.ts, complements the contents of this event handler function. We can pass:

      this.nav.push (newpage)

      This method to jump to newpage this page, at the same time, we can use the

      this.nav.push (newpage, {name "Grey", Job: "IT"});

To send some data to newpage, such as the above means to newpage into the name= "grey", job= "IT",

In NewPage, we can get the corresponding value "grey" and "IT" through. Navparams.get (' name ') and Navparams.get (' job ')

App\pages\home\home.ts Add the following code:

In App\pages\second-page\second-page.ts, add the following code to get the data from the previous page

    • The data came out:

      app\pages\ Second-page\second-page.html:

    • Demo effect: Ionic serve-l

      Click button:

    • In addition, we can add a button in Secondpagepage that returns to the home page,

      app/pages/second-page/second-page.html

      in app/pages/second-page/ Second-page.ts adds an event function to handle the return: This.nav.pop ()

    • Span style= "font-family: Microsoft Jas Black" > Demo effect: Ionic serve-l

      Click the Back button to return to the main page

      ?

------

Previous: Ionic2 study notes (5): Provider

Ionic2 Study Notes (6): NAVIGATION

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.