Code Monkey home page Code Monkey logo

angular-lazy-module's Introduction

angular-lazy-module

Structuring angular app with feature module using Lazy Load feature

Difference between Feature module & root module

  • Feature module provide cohesive set of cuntionality that help application to partition with focused area. It collaborate with root module and other module through service it provide and component, directive & pipes it share.
  • To view the feature module component, it need to export the component in the export array in feature module
  • Feature module are differ with root module, as feature module don't have 'BrowserModule' import which only imported once in root module
  • Commonn module: It contribute many common directive to app template like ngFor, ngIf

Creating simple moduel

  • ng generate module SharedModule
    or
    ng generate module shared --module app.module
    the above command will create the module and make entry into app-module
 import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

@NgModule({
  imports: [
    CommonModule
  ],
  declarations: []
})
export class CustomerDashboard { }
  • Create header, footer, sideNav, directive, pipes etc and import and export same in sharedModule
  • Finally import SharedModule in app-module in Import array
import { SharedModule } from './shared/shared.module';

Creating Feature moduel

ng generate module module/user --route user --module app.module <br />
  
- Above commond will create user module under module folder, create it's route 
- It will also make entry of module in app-module
- Child component will be imported and route accordingly inside route file
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

import { UserRoutingModule } from './user-routing.module';
import { UserComponent } from './user.component';
import { AddUserComponent } from './add-user/add-user.component';
import { ViewUserDetailComponent } from './view-user-detail/view-user-detail.component';
import { EditUserComponent } from './edit-user/edit-user.component';


@NgModule({
  declarations: [UserComponent, AddUserComponent, ViewUserDetailComponent, EditUserComponent],
  imports: [
    CommonModule,
    UserRoutingModule
  ]
})
export class UserModule { }

angular-lazy-module's People

Contributors

kumarmukesh4 avatar mukeshtavant avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.