![](/img/trans.png)
[英]How to pass a value from index.html page to component.ts file in angular 4
[英]how to pass input parameters to an angular 2 component from index.html file
我需要将输入,配置参数设置为index.html中未提及的组件。
我可以看到如何对index.html中包含的组件选择器执行此操作。
如何从index.html进行操作?
您可以在Main模块类中进行如下配置
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};
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.