我在项目中使用了requirejs,angularamd和ui.bootstrap。在弹出窗体的情况下,我从ui.bootstrap获得$ uibModal。但是我无法从resolve中传递参数“items”。如何为已动态解析的控制器注入参数?
'use strict';
define(['application-configuration', 'ajaxService'], function (app) {
function ColSettingController(items) {
var vm = this;
//vm.content = $rootScope.content;
vm.ok = function () {
//$uibModalInstance.close(vm.selected.item);
};
vm.cancel = function () {
//$uibModalInstance.dismiss('cancel');
};
}
app.register.controller("ColSettingController", ColSettingController);
});
这是我想打电话的控制器。
def pick_letter():
while True:
user_choice = input("Would you like a [v]owel or [c]onsonant?")
if user_choice[0].lower() == "v":
return random.choice(vowels)
elif user_choice[0].lower() == "c":
return random.choice(consonants)
else:
print("Unknown Input: %r"%user_choice)
print(pick_letter())
答案 0 :(得分:0)
根据"KGS ID","Latitude","Longitude","Location","Operator","Lease","API","Elevation","Elev_Ref","Depth_start","Depth_stop","URL"
"1002880800","37.2354869","-100.4607509","T32S R29W, Sec. 27, SW SW NE","Stanolind Oil and Gas Co.","William L. Rickers 1","15-119-00164","2705"," KB","2790","7652","http://www.kgs.ku.edu/WellLogs/32S29W/1043696830.zip"
"1002880821","37.1234622","-100.1158111","T34S R26W, Sec. 2, NW NW NE","SKELLY OIL CO","GRACE MCKINNEY 'A' 1","15-119-00181","2290"," KB","4000","5900","http://www.kgs.ku.edu/WellLogs/34S26W/1043696831.zip"
,ui.bootstrap
属性是一个地图对象。 map对象包含键/值对:
resolve
:要注入控制器的依赖项的名称。 {string}
:
如果是{string|function}
,那么它是服务的别名。
否则,如果string
,则将其注入,并将返回值视为依赖项。如果结果是一个promise,则在实例化控制器并将其值注入控制器之前解析它。在您的情况下,您使用的是function
,但您的控制器需要注入load
,我认为它无法说找不到items
,对吧?这是因为你注射的是items
。
您需要在load
,resolve
load
更改您的媒体资源名称。
items
此外,建议在声明控制器/组件和其他之前使用属性resolve: {
//change 'load' for 'items' here
items: [....rest of your code goes here....]
,如下所示:
$inject
希望有所帮助