我有這個服務作爲提供商:如何將一個參數添加到將在組件的構造函數中作爲privider解析的服務?
export class Print {
text: string;
constructor(text: string) {
this.text = text;
}
printText() {
//dosomething with the text;
}
prettifyText() {
//dosomething with the text;
}
}
在我的部分,我想在角在text
解析作爲參數使供應商的一個實例。
const text = 'Something to be printed';
export class AppComponent {
// How to parse 'text' as an argument
// to the printService when it is instantiate
// by angular componennt?
constructor(printService: Print) {
printService.prettifyText();
printServoce.printText();
}
}
你的組件中的文本來自哪裏? – Sasxa
說這是一些全球性的文本(配置文件) –