Angular 5 example
Angular 5 example with angular-js-proxy
by kevinbalicot
HTML
<script src="https://github.com/kevinbalicot/angular-js-proxy/releases/download/v0.4.2/angular-js-proxy.js"></script>
<home-component></home-component>
JavaScript
// ng variable contains { compiler, common, core, router, platformBrowserDynamic, platformBrowser } from Angular 5 library
class Service {
constructor() {}
toUpperCase(string) {
return String(string).toUpperCase();
}
}
// Like @Injectable
Injectable({})(Service);
class HomeComponent {
constructor(service, router) {
this.message = service.toUpperCase('hello');
}
}
// Like @Component
Component({
selector: 'home-component',
providers: [Service, ng.router.Router],
template: `
<h1>{{ message }}</h1>
`
})(HomeComponent);
class Module {
constructor() {}
}
// Like @NgModule
NgModule({
imports: [
ng.platformBrowser.BrowserModule,
ng.router.RouterModule
],
declarations: [HomeComponent],
providers: [],
bootstrap: [HomeComponent]
})(Module);
ng.platformBrowserDynamic.platformBrowserDynamic().bootstrapModule(Module);