<!DOCTYPE html>
<html>

  <head>
    <base href="." />
    <script type="text/javascript" charset="utf-8">
      window.AngularVersionForThisPlunker = 'latest'
    </script>
    <title>angular playground</title>
    <link rel="stylesheet" href="style.css" />
    <script src="https://unpkg.com/core-js@2.4.1/client/shim.min.js"></script>
    <script src="https://unpkg.com/zone.js/dist/zone.js"></script>
    <script src="https://unpkg.com/zone.js/dist/long-stack-trace-zone.js"></script>
    <script src="https://unpkg.com/reflect-metadata@0.1.3/Reflect.js"></script>
    <script src="https://unpkg.com/systemjs@0.19.31/dist/system.js"></script>
    <script src="config.js"></script>
    <script>
    System.import('app')
      .catch(console.error.bind(console));
  </script>
  </head>

  <body>
    <div>This example is a part of the tutorial - <a href="https://angularbytes.witspry.com/2017/10/angular-5-module-and-feature-modules.html">	
https://angularbytes.witspry.com/2017/10/angular-5-module-and-feature-modules.html</a> </div>
    <div style="margin-bottom:20px;"></div>
    <div style="text-align:center;border-bottom-style:solid;"></div>
    <div style="margin-bottom:20px;"></div>
    <my-app>
    loading...
  </my-app>
  </body>

</html>
/* Styles go here */

### Angular Starter Plunker - Typescript
var angularVersion = '@5.0.0';

System.config({
  //use typescript for compilation
  transpiler: 'typescript',
  //typescript compiler options
  typescriptOptions: {
    emitDecoratorMetadata: true
  },
  paths: {
    'npm:': 'https://unpkg.com/'
  },
  //map tells the System loader where to look for things
  map: {
    
    'app': './src',
    '@angular/core': 'npm:@angular/core'+ angularVersion + '/bundles/core.umd.js',
    '@angular/common': 'npm:@angular/common' + angularVersion + '/bundles/common.umd.js',
    '@angular/common/http': 'npm:@angular/common' + angularVersion + '/bundles/common-http.umd.js',
    '@angular/compiler': 'npm:@angular/compiler' + angularVersion  + '/bundles/compiler.umd.js',
    '@angular/platform-browser': 'npm:@angular/platform-browser' + angularVersion + '/bundles/platform-browser.umd.js',
    '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic' + angularVersion + '/bundles/platform-browser-dynamic.umd.js',
    '@angular/http': 'npm:@angular/http' + angularVersion + '/bundles/http.umd.js',
    '@angular/router': 'npm:@angular/router' + angularVersion +'/bundles/router.umd.js',
    '@angular/forms': 'npm:@angular/forms' + angularVersion + '/bundles/forms.umd.js',
    '@angular/animations': 'npm:@angular/animations' + angularVersion + '/bundles/animations.umd.js',
    '@angular/platform-browser/animations': 'npm:@angular/platform-browser' + angularVersion + '/bundles/platform-browser-animations.umd.js',
    '@angular/animations/browser': 'npm:@angular/animations' + angularVersion + '/bundles/animations-browser.umd.js',
    
    '@angular/core/testing': 'npm:@angular/core' + angularVersion + '/bundles/core-testing.umd.js',
    '@angular/common/testing': 'npm:@angular/common' + angularVersion + '/bundles/common-testing.umd.js',
    '@angular/common/http/testing': 'npm:@angular/common' + angularVersion + '/bundles/common-http-testing.umd.js',
    '@angular/compiler/testing': 'npm:@angular/compiler' + angularVersion + '/bundles/compiler-testing.umd.js',
    '@angular/platform-browser/testing': 'npm:@angular/platform-browser' + angularVersion + '/bundles/platform-browser-testing.umd.js',
    '@angular/platform-browser-dynamic/testing': 'npm:@angular/platform-browser-dynamic' + angularVersion + '/bundles/platform-browser-dynamic-testing.umd.js',
    '@angular/http/testing': 'npm:@angular/http' + angularVersion + '/bundles/http-testing.umd.js',
    '@angular/router/testing': 'npm:@angular/router' + angularVersion + '/bundles/router-testing.umd.js',
    'tslib': 'npm:tslib@1.6.1',
    'rxjs': 'npm:rxjs@5.0.0',
    'typescript': 'npm:typescript@2.2.1/lib/typescript.js'
  },
  //packages defines our app package
  packages: {
    app: {
      main: './main.ts',
      defaultExtension: 'ts'
    },
    rxjs: {
      defaultExtension: 'js'
    }
  }
});
//main entry point
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import {AppModule} from './app';

platformBrowserDynamic().bootstrapModule(AppModule)
//our root app component
import {Component, NgModule, VERSION} from '@angular/core'
import {BrowserModule} from '@angular/platform-browser'
import {MailClient} from './mailClient'
import {MailBoxModule} from './MailBox/mailBox.module'
import {AddressBookModule} from './AddressBook/addressBook.module'

@Component({
  selector: 'my-app',
  template: `
    <div>
      <mail-client [version]='1.2'></mail-client>
      <mail-box></mail-box>
      <address-book></address-book>
    </div>
  `,
})
export class App {
  
  constructor() {
    
  }
}

@NgModule({
  imports: [ BrowserModule, MailBoxModule, AddressBookModule ],
  declarations: [ App, MailClient ],
  bootstrap: [ App ]
})
export class AppModule {}
import {Component, Input} from '@angular/core'

@Component({
  selector: 'mail-client',
  template: `
    <div>
      <h2>MailClient : v - {{version}} </h2>
    </div>
  `
})
export class MailClient {
  @Input() version:number;
  constructor(){
   
  }

}
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { MailBoxComponent } from './mailBox.component'
import { MailBoxService } from './mailBox.service'

@NgModule({
  imports:      [ CommonModule ],
  declarations: [ MailBoxComponent ],
  exports:      [ MailBoxComponent ],
  providers:    [ MailBoxService ]
})
export class MailBoxModule { }
import { Component } from '@angular/core'
import { MailBoxService } from './mailBox.service'

@Component({
  selector: 'mail-box',
  template: `
    <div>
      <h2>Mail Box</h2>
      <div *ngFor='let ibMail of inboxMails; let idx = index'>
        <div>{{idx+1}} - {{ibMail}}</div>
      </div>
    </div>
  `
})
export class MailBoxComponent implements OnInit{
  inboxMails:string[];
  constructor(private _service: MailBoxService){
   
  }
  
  ngOnInit(){
    this.inboxMails = this._service.getInboxMails();
  }

}
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { AddressBookComponent } from './addressBook.component'
import { AddressBookService } from './addressBook.service'

@NgModule({
  imports:      [ CommonModule ],
  declarations: [ AddressBookComponent ],
  exports:      [ AddressBookComponent ],
  providers:    [ AddressBookService ]
})
export class AddressBookModule { }
import { Component } from '@angular/core'
import { AddressBookService } from './addressBook.service'

@Component({
  selector: 'address-book',
  template: `
    <div>
      <h2>Address Book</h2>
      <div *ngFor='let contact of contacts; let idx = index'>
        <div>{{idx+1}} - {{contact}}</div>
      </div>
    </div>
  `
})
export class AddressBookComponent implements OnInit{
  contacts : string[];
  constructor(private _service : AddressBookService){
   
  }
  
  ngOnInit(){
    this.contacts = this._service.getContacts();
  }

}
import {Injectable} from '@angular/core'

@Injectable()
export class MailBoxService {
  constructor(){
    
  }
  
  getInboxMails():string[] {
    return [
      "Welcome to MailClient",
      "Daily Newsletter",
      "20% discount on this product"
      ]; 
  }
}
import {Injectable} from '@angular/core'

@Injectable()
export class AddressBookService {
  constructor(){
    
  }
  
  getContacts():string[] {
    return [
      "Alice (alice@example.com)",
      "Bob (bob@example.com)",
      "Chris (chris@example.com)"
      ];
  }
}