Reputation: 215
I am really lost with RC6 of angular2.
I don't manage to adapt my code with module and component and don't understand the differences between the two. Could you help me in integrating directives, providers, imports for a large scale applications.
The Google's documentation is not so clear yet.
Thanks in advance.
Cheers
Upvotes: 3
Views: 1286
Reputation: 7037
Forget about all those boring tech spec, they just confused you more. I don't really believe there is such need to have two concepts, because in programming language they can be referred interchangeably, like we say vehicles and cars. Many articles on Angular2 don't refer to them distinguishably for general discussion until actual coding.
However here are the two key differences when looking at code:
- Component has class, template and metadata.
- Component is child of Module, meaning Module is always at a higher level of Component.
About No. 2, that said means Component is the leaf-level in the Angular2 structure. Here is a very good explanation.
Upvotes: 1
Reputation: 4071
Basically, in Angular2, you have :
Modules : These are used to basically setup the logic of your application : How things are linked to each other. You start your application on bootstrapping a module.
Components : A "WebComponent" where you set the html to be injected into your navigator, with the associated CSS and it's behavior.
Services or Directives : Where you need to execute some app logic such as Authentication calls, states and so on.
A Router with outlets : That defines how you navigate in your application, based on the URL.
I tried to explain this with my own words so it's IS inaccurate on several levels, and that is why you have documentation sites such as angular.io. Hope this helps.
Official documentation on Modules => https://angular.io/docs/ts/latest/guide/ngmodule.html
Upvotes: 2