<!DOCTYPE html>
<html>

  <head>
    <base href="." />
    <title>Angular2 Cookie Law with Angular4</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@0.7.2/dist/zone.js"></script>
    <script src="https://unpkg.com/zone.js@0.7.2/dist/long-stack-trace-zone.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>
    <my-app>
    loading...
  </my-app>
  </body>

</html>
body {
  padding-top: 50px;
}

a.link {
  color: blue;
}

a.link:hover {
  color: blue;
}

.container {
  margin: 10px 0;
}

.container button {
  padding: 10px;
  margin: 5px 0;
  font-size: 16px;
}
### Angular Starter Plunker - Typescript
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@4.0.0/bundles/core.umd.js',
    '@angular/common': 'npm:@angular/common@4.0.0/bundles/common.umd.js',
    '@angular/compiler': 'npm:@angular/compiler@4.0.0/bundles/compiler.umd.js',
    '@angular/animations': 'npm:@angular/animations@4.0.0/bundles/animations.umd.js',
    '@angular/platform-browser/animations': 'npm:@angular/platform-browser@4.0.0/bundles/platform-browser-animations.umd.js',
    '@angular/platform-browser': 'npm:@angular/platform-browser@4.0.0/bundles/platform-browser.umd.js',
    '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic@4.0.0/bundles/platform-browser-dynamic.umd.js',
    '@angular/animations/browser': 'npm:@angular/animations@4.0.0/bundles/animations-browser.umd.js',
    
    'angular2-cookie-law': 'npm:angular2-cookie-law@1.3.0/bundles/angular2-cookie-law.umd.js',
    'rxjs': 'npm:rxjs@5.2.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, 
  ViewChild,
} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { CookieLawModule } from 'angular2-cookie-law';

@Component({
  selector: 'my-app',
  template: `
    <h1>Hello {{name}}</h1>
    <span>Demo page</span>

    <div class="container">
      <button type="button"
              *ngIf="!cookieLawSeen"
              (click)="dismiss()">Dismiss Modal</button>

      <h3 *ngIf="cookieLawSeen">Cookie law dismissed</h3>
    </div>

    <div>
      <a class="link"
         href="https://github.com/andreasonny83/angular2-cookie-law">
       Fork me on GitHub
      </a>
    </div>

    <cookie-law position="top" name="ng4topCookieLaw" expiration="1">
      Allo! This is my awesome cookie-law message that expires tomorrow.
      <a href="https://github.com/andreasonny83/angular2-cookie-law">
        Click here for more info
      </a>
    </cookie-law>

    <cookie-law #cookieLaw 
                name="ng4CookieLaw"
                (isSeen)="cookieLawSeen = $event"
                learnMore="/false" 
                target="_blank"></cookie-law>
  `,
})
export class App implements OnInit {
  @ViewChild('cookieLaw') 
  cookieLawEl: any;
  
  cookieLawSeen: boolean;
  name: string;
  
  constructor() {
    this.name = 'Angular2 Cookie Law with Angular4'
  }
  
  ngOnInit() {
    this.cookieLawSeen = this.cookieLawEl.cookieLawSeen;
  }

  dismiss(): void {
    this.cookieLawEl.dismiss();
  }
}

@NgModule({
  imports: [ 
    BrowserModule,
    BrowserAnimationsModule,
    CookieLawModule,
  ],
  declarations: [ App ],
  bootstrap: [ App ]
})
export class AppModule {}