Does @NgModules connect by declaring directives, services, etc. At the root level?

I just updated to angular2 RC5 and red this article on @NgModules.
https://angularjs.blogspot.de/2016/08/angular-2-rc5-ngmodules-lazy-loading.html

With @NgModulescomponents, directives, services, etc. are declared at the root level of the modules. My thought about this was: are we not trying to share thoughts and are we trying to archive building components that can be used even by ourselves?

And if I now have a component, for example, "NoteCard", which is used in the "container", the "Notes" component.

NoteCard:

import {Component} from "@angular/core";

@Component({
    selector: 'note-card',
    styleUrls: ['app/ui/note-card/note-card.css'],
    templateUrl: 'app/ui/note-card/note-card.html'
})
export class NoteCard {}

Notes:

import {Component} from "@angular/core";
import {NoteCard, NoteCreator} from "../../ui";
import {NotesService} from "../../services";

@Component({
    selector: 'notes-container',
    directives: [
        NoteCard
    ],
    styleUrls: ['app/containers/notes/notes.css'],
    templateUrl: 'app/containers/notes/notes.html'
})
export class Notes {}

RC4 "NoteCard" "". "NoteCard" (, ) "" "NoteCard" , .

RC5 "NoteCard" @NgModule. , , , .

@NgModule ? "" - @NgModule?

0
1
+1

Source: https://habr.com/ru/post/1651486/


All Articles