2

I can't completely understand the difference between pages and components in ionic.

As far as I understand @IonicPage() enables us to lazy-load the page but what really grinds my gears is that none of the provided examples utilize that (all of them seem to use components as top-level pages).

I am wondering when should I use pages and when components, since they both are easy to generate with the CLI.

Any input and information on the topic is greatly appreciated.

Biser A.
  • 154
  • 1
  • 13
  • 2
    Hope this helps to you:https://stackoverflow.com/questions/45279191/ionic-3-component-vs-page – Sampath Aug 16 '17 at 04:15

1 Answers1

3

page's and component's are really the same thing. The concept of a page is an Ionic thing, and they are meant to be used as a screen (eq a 'home-page' or 'contact-page') in your app. While a component is meant to be used as a part of a page (eg custom-contact-card).

According to this SO-answer, a component is considered a page when it gets pushed onto the NavController stack.

The @IonicPage() and lazy-loading is quite new and it is possible that the examples your looking at was made before @IonicPage() came around. This blog series gives an excellent explanation:
Part 1
Part 2

robbannn
  • 5,001
  • 1
  • 32
  • 47