Reputation: 9261
I am trying to play Angular2, and when I upgraded the base codes to Angular 2.0.0-RC5, I found a breaking changes introduced, @NgModule, which is equivalent with angular.moudle() in Angularjs 1.x?
For me, @ngModule make things complex.
When I was using Angular 1.x, there are some complaints in communities about angular.module, because there are some javascript module systems existed.
By default, Angular-cli generated codes are based SystemJS, we can use Typescirpt to organize the structure of source codes.
Why we need @NgModule, it is a logic view of the application organization at runtime?
I assume a @NgModule is designated for module based architecture for Angular2, and a @ngModule can be reused in different applications. Compare to other module/bundle/plugin based frameworks I have used in the past years. It lacks some features.
Why route config is registered by RouteModule.forRoot()(or forChild) not a route attribute of @NgModule annotation like this.
@NgModule(route:{prefix:'/comment', config: commentRouteConfigs})
export class CommentModule{}
Currently, the @NgModule API coupled route configs.
How to override the component template defined in a @NgModule when I import a module in a host module.
Thanks.
Upvotes: 4
Views: 2061
Reputation: 657118
As far as I know NgModule
was mainly introduced to properly support lazy loading of routes and components by the router.
NgModule
s import and export is not related to TS import and export. It is mostly about dependency injection and compiling templates.
don't know
don't understand the question
Overriding templates is not supported by Angular2 at all. There are build tools that allow that, but Angular2 itself doesn't provide anything to do that.
I have seen module lifecycle callbacks seen mentioned in discussions but couldn't find anything concrete yet (like https://github.com/angular/angular/issues/10808#issuecomment-239823985)
I guess it's possible but I have no idea if the Angular2 team does consider this.
Upvotes: 3