Component with

后端 未结 2 1919
暗喜
暗喜 2020-12-03 02:57

I\'ve seen working examples when is beeing used inside other nested components (like here) but I haven\'t managed to run it inside a root Ang

2条回答
  •  生来不讨喜
    2020-12-03 03:59

    Turns out it's possible, if you intend to provide textual content. If you want Angular components, it's possible with the right HTML element (noscript). A little hacky, one might say. The trick is using a

    HTML template:

    
    
    

    Root component:

    import {Component, bootstrap} from 'angular2/angular2';
    
    @Component({
        selector: 'app',
        template: 'Header: ' + window.mainTemplate ,
    })
    export class App {
    }
    
    bootstrap(App);
    

    Make sure your Angular 2 code comes after the template definition.

    Only applies if you use a