How can i add/integrate an Angular 6 application into an existing HTML site, can I include it as a single JS file ?
How can I bundle an Angular App into a single JS file ?
Thanks
How can i add/integrate an Angular 6 application into an existing HTML site, can I include it as a single JS file ?
How can I bundle an Angular App into a single JS file ?
Thanks
Here is a CodePen working with Angular stubbed into it. Remember this is development mode and you'll want to compile for production to get all the deployable files webpacked and ready.
Angular files (development files hosted at a CDN, add them to head)
https://cdnjs.cloudflare.com/ajax/libs/rxjs/6.2.1/rxjs.umd.min.js https://cdnjs.cloudflare.com/ajax/libs/core-js/2.5.7/core.js https://unpkg.com/@angular/core@6.0.5/bundles/core.umd.js https://cdnjs.cloudflare.com/ajax/libs/zone.js/0.8.26/zone.min.js https://unpkg.com/@angular/common@6.0.5/bundles/common.umd.js https://unpkg.com/@angular/compiler@6.0.5/bundles/compiler.umd.js https://unpkg.com/@angular/platform-browser@6.0.5/bundles/platform-browser.umd.js https://unpkg.com/@angular/platform-browser-dynamic@6.0.5/bundles/platform-browser-dynamic.umd.js https://unpkg.com/@angular/forms@6.0.5/bundles/forms.umd.js
Your index.html file
<my-app></my-app> // Angular should load in here
Your .ts file (compile it to js to add to head)
@Component({
selector: 'my-app',
template: `
<input-textarea (OutputEvent)="receiveValue($event)"></input-textarea>
<expander [textInput]="value"></expander>
`
})
class AppComponent {
value: string = '';
constructor() {}
public receiveValue(val){
this.value = val;
}
}
// main.js
const { BrowserModule } = ng.platformBrowser;
const { NgModule } = ng.core;
const { CommonModule } = ng.common;
@NgModule({
imports: [
BrowserModule,
CommonModule
],
declarations: [AppComponent],
bootstrap: [AppComponent],
providers: []
})
class AppModule {}
const { platformBrowserDynamic } = ng.platformBrowserDynamic;
platformBrowserDynamic().bootstrapModule(AppModule).catch(err => console.error(err));