My questions is … what should i use when creating an app … Pages or Components? i don’t understand the difference. Can anybody explain me this?
It’s certainly a little confusing, but I’ll take a stab at clarifying.
A component is basically anything with a template (i.e. the HTML file) and a controller (i.e. the TypeScript file). In general Ionic terms, a component is something that you’d put onto a page. So if you have a Model that you consistently render a certain way, you might create a MyModelComponent so that you can easily place on your page.
<my-model [model]="modelToDisplay"></my-model>
However, like I said before a Component is basically just a view + a controller, and so a Page also receives the @Component
decorator, e.g.
@Component({
selector: 'page-tabs',
templateUrl: 'home.html',
})
export class HomePage {
...
}
So to back up a bit, pages are normally what you’re using (and what the NavController
uses), but if you have some HTML that you’re re-using then you’d create a Component.
Hopefully this helps.