python ruby-programming-language Smalltalk Vue.js Knockoutjs TypeScript JavaScript, OOPs JavaScript Angular 7, Interview Questions Angular 8,7,6,5,4 and 2 Interview Questions and Answers Angular 8,7,6,5,4 and 2 Interview Questions and Answers Angular 4 Angular 2 AngularJs 1.x NodeJs Perl Programming R Programming RequireJs Rust Programming Backbonejs closure programming language go-programming-language kotlin-programming-language
@NgModule decorator

What classes should you not add to module declarations?

NgModule Declarations Array List -
We do not declare - Modules, Services, objects, and non-angular helper classes in the module's declarationsStayed Informed What Is Modules?

Syntax for NgModule declaration Array -
  declarations: [

The non-Angular classes and objects as following as -
1.      Strings
2.      Numbers
3.      Functions
4.      Entity Models
5.      Configurations
6.      and other helper classes

Note - You can use directives, components, and pipes classes in a module declaration.

The example of what goes into declarations array list –
//JavaScript imports directives, components, and pipes classes
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { LoginComponent } from './login/login.component';
import { MyPipe } from './my-pipe.pipe';
import { MyDirective } from './my-directive.directive';
import {MySericeService} from './my-serice.service';
import{MyModuleModule} from '../app/my-module/my-module.module';
//AppModule class with the @NgModule decorator.
  declarations: [
  imports: [//DOM rendering, sanitization, and location
  providers: [//service providers
  bootstrap: [AppComponent]  // bootstrapped entry component
export class AppModule {
  //exporting app module

You can see in the above example, I have created and declared components, directives and pipes in the @NgModule class using the CLI commands.
1.      ng g component my-component
2.      ng g pipe my-pipe
3.      ng g directive my-directive
4.      ng g service mySerice
5.      ng g module myModule

These CLI commands automatically imported components, directives, and pipes classes inside the module.

Hi there! Welcome to my blog. My name is Anil Singh. I'm a author of this blog. For more detail about me, kindly refer to this link..
My Blogs - and
My Books - Interview Questions and Answers Books- Get Your Book in 15+ Digital Stores Worldwide..

You Might Also Like Powered by Blogger.
ASK Questions