2017-03-09 49 views

回答

0

你可以有你的配置在主模块类,如下

import {Component, NgModule} from '@angular/core' 
import {BrowserModule} from '@angular/platform-browser' 

@Component({ 
    selector: 'my-app', 
    template: ` 
    <div> 
     <h2>{{name}} Sample</h2> 
     {{myConfiguration | json}} 
    </div> 
    `, 
}) 
export class App { 
    name:string; 
    myConfiguration:any=myConfiguration; 
    constructor() { 
    console.log(myConfiguration); 
    this.name = 'Global Configuration' 
    } 
} 

@NgModule({ 
    imports: [ BrowserModule ], 
    declarations: [ App ], 
    bootstrap: [ App] 
}) 
export class AppModule { 
    var myConfiguration={id:1,devmode:true}; 

} 

LIVE DEMO

+0

没有办法中的index.html做到这一点? – reza

相关问题