I am using this as an example: JSFiddle - angular2 example My goal is to use angular4 in a single html file and create a single page application without webpack and pipes.
And this is my code, which is currently not working.
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="https://unpkg.com/[email protected]/client/shim.min.js"></script>
<script type="text/javascript" src="https://unpkg.com/[email protected]/dist/zone.min.js"></script>
<script type="text/javascript" src="https://unpkg.com/[email protected]/bundles/Rx.min.js"></script>
<script type="text/javascript" src="https://unpkg.com/@angular/[email protected]/bundles/core.umd.js"></script>
<script type="text/javascript" src="https://unpkg.com/@angular/[email protected]/bundles/common.umd.js"></script>
<script type="text/javascript" src="https://unpkg.com/@angular/[email protected]/bundles/compiler.umd.js"></script>
<script type="text/javascript" src="https://unpkg.com/@angular/[email protected]/bundles/platform-browser.umd.js"></script>
<script type="text/javascript" src="https://unpkg.com/@angular/[email protected]/bundles/platform-browser-dynamic.umd.js"></script>
<script type="text/typescript">
let { Component, NgModule } = ng.core;
@Component({
selector: 'my-app',
template: `
<h1>Hello, {{ name }}</h1>
<button (click)="increment()">Click {{ counter }}</button>
`,
})
class HomeComponent {
counter = 0;
name = 'Angular 2'
increment() {
this.counter++;
}
}
const { BrowserModule } = ng.platformBrowser;
@NgModule({
imports: [ BrowserModule ],
declarations: [ HomeComponent ],
bootstrap: [ HomeComponent ]
})
class AppModule { }
const { platformBrowserDynamic } = ng.platformBrowserDynamic;
platformBrowserDynamic().bootstrapModule(AppModule);
</script>
</head>
<body>
<my-app></my-app>
</body>
</html>
@component and @Modulemetadata. you need to compile it to java script for it to work