望着答案在這裏注入語法: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