望着答案在这里注入语法:https://stackoverflow.com/a/19272093/2547709
使用$注入语法我控制器结束这样看:
class MyCtrl {
public static $inject: string[] = ['$scope'];
constructor($scope){
// stuff
}
}
// register the controller
app.controller("MyCtrl", MyCtrl);
我的问题是 - 如果我发生了什么想自己的自定义参数传递给构造以及任何注入的变量?:
class MyCtrl {
public static $inject: string[] = ['$scope'];
constructor($scope, customArg){
// stuff
}
}
// Now how do I pass customArg in without it complaining?
app.controller("MyCtrl", MyCtrl(customArg)); // Nope
我觉得我失去了一些东西根本,用这种语法,你传递给.controller()函数的所有东西都必须使用angular注册,所以我不应该试图传入自定义参数?或者我可以传递一个任意的值/对象?如果是的话如何?
什么是你想传递的东西的例子?你可以使用angular.value以角度注册它吗? – 2014-09-12 16:50:06