<!DOCTYPE html>
<html>
  <head>
    <title>Angular Quickstart</title>
    <script>document.write('<base href="' + document.location + '" />');</script>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <style>
      body {color:#369;font-family: Arial,Helvetica,sans-serif;}
    </style>

    <!-- Polyfills -->
    <script src="https://unpkg.com/core-js/client/shim.min.js"></script>

    <script src="https://unpkg.com/zone.js@0.8.4?main=browser"></script>
    <script src="https://unpkg.com/systemjs@0.19.39/dist/system.src.js"></script>
    <script src="systemjs.config.js"></script>
    <script>
      System.import('main.js').catch(function(err){ console.error(err); });
    </script>
  </head>
  

  <body>
    <my-app>Loading AppComponent content here ...</my-app>
  </body>

</html>


import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';

import { AppModule } from './app/app.module';

platformBrowserDynamic().bootstrapModule(AppModule);


var templateUrlRegex = /templateUrl\s*:(\s*['"`](.*?)['"`]\s*)/gm;
var stylesRegex = /styleUrls *:(\s*\[[^\]]*?\])/g;
var stringRegex = /(['`"])((?:[^\\]\\\1|.)*?)\1/g;

module.exports.translate = function(load){
  if (load.source.indexOf('moduleId') != -1) return load;

  var url = document.createElement('a');
  url.href = load.address;

  var basePathParts = url.pathname.split('/');

  basePathParts.pop();
  var basePath = basePathParts.join('/');

  var baseHref = document.createElement('a');
  baseHref.href = this.baseURL;
  baseHref = baseHref.pathname;

  if (!baseHref.startsWith('/base/')) { // it is not karma
    basePath = basePath.replace(baseHref, '');
  }

  load.source = load.source
    .replace(templateUrlRegex, function(match, quote, url){
      let resolvedUrl = url;

      if (url.startsWith('.')) {
        resolvedUrl = basePath + url.substr(1);
      }

      return 'templateUrl: "' + resolvedUrl + '"';
    })
    .replace(stylesRegex, function(match, relativeUrls) {
      var urls = [];

      while ((match = stringRegex.exec(relativeUrls)) !== null) {
        if (match[2].startsWith('.')) {
          urls.push('"' + basePath + match[2].substr(1) + '"');
        } else {
          urls.push('"' + match[2] + '"');
        }
      }

      return "styleUrls: [" + urls.join(', ') + "]";
    });

  return load;
};
/**
 * WEB ANGULAR VERSION
 * (based on systemjs.config.js in angular.io)
 * System configuration for Angular samples
 * Adjust as necessary for your application needs.
 */
(function (global) {
  System.config({
    // DEMO ONLY! REAL CODE SHOULD NOT TRANSPILE IN THE BROWSER
    transpiler: 'ts',
    typescriptOptions: {
      // Copy of compiler options in standard tsconfig.json
      "target": "es5",
      "module": "commonjs",
      "moduleResolution": "node",
      "sourceMap": true,
      "emitDecoratorMetadata": true,
      "experimentalDecorators": true,
      "lib": ["es2015", "dom"],
      "noImplicitAny": true,
      "suppressImplicitAnyIndexErrors": true
    },
    meta: {
      'typescript': {
        "exports": "ts"
      }
    },
    paths: {
      // paths serve as alias
      'npm:': 'https://unpkg.com/'
    },
    // map tells the System loader where to look for things
    map: {
      // our app is within the app folder
      'app': 'app',

      // angular bundles
      '@angular/animations': 'npm:@angular/animations@4.1.2/bundles/animations.umd.js',
      '@angular/animations/browser': 'npm:@angular/animations@4.1.2/bundles/animations-browser.umd.js',
      '@angular/core': 'npm:@angular/core@4.1.2/bundles/core.umd.js',
      '@angular/common': 'npm:@angular/common@4.1.2/bundles/common.umd.js',
      '@angular/compiler': 'npm:@angular/compiler@4.1.2/bundles/compiler.umd.js',
      '@angular/platform-browser': 'npm:@angular/platform-browser@4.1.2/bundles/platform-browser.umd.js',
      '@angular/platform-browser/animations': 'npm:@angular/platform-browser@4.1.2/bundles/platform-browser-animations.umd.js',
      '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic@4.1.2/bundles/platform-browser-dynamic.umd.js',
      '@angular/http': 'npm:@angular/http@4.1.2/bundles/http.umd.js',
      '@angular/router': 'npm:@angular/router@4.1.2/bundles/router.umd.js',
      '@angular/router/upgrade': 'npm:@angular/router@4.1.2/bundles/router-upgrade.umd.js',
      '@angular/forms': 'npm:@angular/forms@4.1.2/bundles/forms.umd.js',
      '@angular/upgrade': 'npm:@angular/upgrade@4.1.2/bundles/upgrade.umd.js',
      '@angular/upgrade/static': 'npm:@angular/upgrade@4.1.2/bundles/upgrade-static.umd.js',

      // other libraries
      'rxjs':                      'npm:rxjs@5.0.1',
      'angular-in-memory-web-api': 'npm:angular-in-memory-web-api@0.2.4/bundles/in-memory-web-api.umd.js',
      'ts':                        'npm:plugin-typescript@5.2.7/lib/plugin.js',
      'typescript':                'npm:typescript@2.2.1/lib/typescript.js',

    },
    // packages tells the System loader how to load when no filename and/or no extension
    packages: {
      app: {
        main: './main.ts',
        defaultExtension: 'ts',
        meta: {
          './*.ts': {
            loader: 'systemjs-angular-loader.js'
          }
        }
      },
      rxjs: {
        defaultExtension: 'js'
      }
    }
  });

})(this);

import {Component, ChangeDetectorRef} from '@angular/core';
import {MapsAPILoader} from "@agm/core";
import {NgForm} from "@angular/forms";


@Component({
  selector: 'my-app',
  styleUrls : [
    `./my-app.css`,
  ],
  // encapsulation:ViewEncapsulation.Emulated
  template: `
    <div class="title">demo</div>
    <child-comp></child-comp>
    <child-comp class="test-red"></child-comp>
  `
  
})

export class AppComponent {
  

}

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';

import { AppComponent } from './app.component';
import { ChildComp } from './ChildComp';
import {CommonModule} from "@angular/common";
import {AgmCoreModule} from "@agm/core";


@NgModule({
  declarations: [
    AppComponent,
    ChildComp
  ],
  imports: [
    BrowserModule,
    FormsModule,
    HttpModule,
    CommonModule,

  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }
import {Component, ChangeDetectorRef} from '@angular/core';
import {MapsAPILoader} from "@agm/core";
import {NgForm} from "@angular/forms";


@Component({
  selector: 'child-comp',
  styleUrls : [
    `./child-comp.css`,
  ],
  // encapsulation:ViewEncapsulation.Emulated
  template: `
    <div>Child Component</div>
  `
  
})

export class ChildComp {
  

}
@charset "UTF-8";

.title {
  color: green;
}
@charset "UTF-8";

:host(.test-red) div {
  color: red;
}