<!DOCTYPE html>
<html>
<head>
<title>ViewEncapsulation Demo</title>
<link rel="stylesheet" href="style.css" />
<script src="https://code.angularjs.org/2.0.0-beta.10/angular2-polyfills.js"></script>
<script src="https://code.angularjs.org/tools/system.js"></script>
<script src="https://code.angularjs.org/tools/typescript.js"></script>
<script src="config.js"></script>
<script src="https://code.angularjs.org/2.0.0-beta.10/Rx.js"></script>
<script src="https://code.angularjs.org/2.0.0-beta.10/angular2.dev.js"></script>
<script>
System
.import('app')
.catch(console.error.bind(console));
</script>
</head>
<body>
<my-app>
Loading...
</my-app>
</body>
</html>
/* Styles go here */
System.config({
transpiler: 'typescript',
typescriptOptions: {
emitDecoratorMetadata: true
},
map: {
app: './app'
},
packages: {
app: {
main: './main.ts',
defaultExtension: 'ts'
}
}
});
import {bootstrap} from 'angular2/platform/browser';
import {AppComponent} from './app.component';
bootstrap(AppComponent);
import {Component} from 'angular2/core';
import {MyComponent} from './my-component.component';
@Component({
selector: 'my-app',
template: `
<div class="app">
<my-component>
<div class="my-component-title">
This is the Component title!
</div>
<div class="my-component-content">
And here's some awesome content.
</div>
</my-component>
</div>
`,
directives: [
MyComponent
]
})
export class AppComponent {
}
import {Component} from 'angular2/core';
@Component({
selector: 'my-component',
template: `
<div class="my-component">
<div>
Title:
<ng-content select=".my-component-title"></ng-content>
</div>
<div>
Content:
<ng-content select=".my-component-content"></ng-content>
</div>
</div>
`
})
export class MyComponent {
}