[英]Angular 2 provide() with string in ES5?
我正在尝试使用String作为提供而不是类的标记:
app.RandomComponent = ng.core
.Component({
selector: "randomComponent",
template: "Component!",
providers: [
ng.core.provide("Stuff", {useValue: "Hello"})
]
})
.Class({
constructor: ["Stuff", function(stuff) {
}]
});
但是,它引发错误: EXCEPTION: Cannot resolve all parameters for 'class5'(Stuff). Make sure that all the parameters are decorated with Inject or have valid type annotations and that 'class5' is decorated with Injectable.
EXCEPTION: Cannot resolve all parameters for 'class5'(Stuff). Make sure that all the parameters are decorated with Inject or have valid type annotations and that 'class5' is decorated with Injectable.
根据https://angular.io/docs/ts/latest/api/core/Provider-class.html,它应该至少在TS中起作用:/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.