This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Component } from '@angular/core'; | |
| @Component({ | |
| selector: 'app-root', | |
| template: ` | |
| <h1>My App</h1> | |
| <nav> | |
| <a routerLink="eager">Eager</a> | |
| <a routerLink="lazy">Lazy</a> | |
| </nav> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { ModuleWithProviders } from '@angular/core'; | |
| import { Routes, RouterModule } from '@angular/router'; | |
| import { EagerComponent } from './eager.component'; | |
| const routes: Routes = [ | |
| { path: '', redirectTo: 'eager', pathMatch: 'full' }, | |
| { path: 'eager', component: EagerComponent }, | |
| { path: 'lazy', loadChildren: 'lazy/lazy.module#LazyModule' } | |
| ]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Component } from '@angular/core'; | |
| @Component({ | |
| template: '<p>Eager Component</p>' | |
| }) | |
| export class EagerComponent {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { NgModule } from '@angular/core'; | |
| import { LazyComponent } from './lazy.component'; | |
| import { routing } from './lazy.routing'; | |
| @NgModule({ | |
| imports: [routing], | |
| declarations: [LazyComponent] | |
| }) | |
| export class LazyModule {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { ModuleWithProviders } from '@angular/core'; | |
| import { Routes, RouterModule } from '@angular/router'; | |
| import { LazyComponent } from './lazy.component'; | |
| const routes: Routes = [ | |
| { path: '', component: LazyComponent } | |
| ]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Component } from '@angular/core'; | |
| @Component({ | |
| template: '<p>Lazy Component</p>' | |
| }) | |
| export class LazyComponent {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public interface Selector { | |
| public void registerObserver(Observer observer); | |
| public void removeObserver(Observer observer); | |
| public void notifyObservers(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public interface Observer { | |
| public void update(String status); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.ArrayList; | |
| import java.util.List; | |
| public class FlipkartMINote5Pro implements Selector{ | |
| private List<Observer> observers = new ArrayList<Observer>(); | |
| private String productStatus; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class AkhilCustomer implements Observer { | |
| @Override | |
| public void update(String status) { | |
| if(status.equals("Available")) | |
| System.out.println("Akhil: Its too Late, I am not planning to buy the phone!!!!"); | |
| } | |
| } |