João Paiva João Paiva - 8 months ago 86
Javascript Question

AngularJS 2 CRUD Components

I'm getting started with AngularJS 2 with TypeScript and I'm trying to find the best way of organizing my application.

Imagine that I want to CRUD a product. Since I want each CRUD operation to have different views should I create a component for each operation? For example: createProduct.component; editProduct.component; getProduct.component; etc.; that all reuse the product class and the product.service in order to make http requests to the server?

I think this makes sense, but I'm not sure there's a better way to do it and since AngularJS 2 is fairly new, I'm having trouble finding proper documentation for this problem. Any thoughts?

  • Create a /+product folder
  • Add all product components (edit/view/create), also include the test(product.spec.ts) files
  • Create a /services folder, add the product.service