html5 - How to correctly decide what should be a component in Angular 2? -


i find angular 2 components nice, can write down our own html elements suited app building, however, since i'm getting started angular 2, feel i'm using them wrong way around.

the way i've been using components, , i've seem other people doing, make 1-1 correspondence between components , views.

in other words, each view of app, 1 creates 1 component , use router trigger active component.

so in setting 1 have components this:

  • dashboard component - dashboard view
  • user profile component - user profile view
  • sales list component - sales list view
  • sale editor component - sale editor view, used both adding new sale or updating one

and forth. mean, works, feel wrong way use components. seems me somehow components should more granular that.

how should 1 correctly decide must component in angular 2? should 1 make 1-1 mapping between components or view? if not, right way decide components need build?

this question opinion based , not fit so.

your above list of when build components right,

but component can consist of 0 many components.

if take @ https://github.com/angular/material2, you'll see there simple components input elements, button, tooltip, ... more complex components tab, menu, dialog.

as class design, build component 1 thing , well. build more complex components using basic components.


Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -