我想通过参数传递值到模态。出于某种原因,当我尝试在控制器中访问它时,此参数始终为undefined
。 this question的第二个答案是我正在构建的。为什么这个模态参数总是不确定的?
这是我的模态设置。请注意,$scope.evaluationResult
已定义并具有有效内容。
$scope.showEvaluationResult = function() {
var modalInstance = $modal.open({
templateUrl: 'evaluation-result/evaluation-result-dlg.html',
controller: 'EvaluationResultDialogCtrl',
windowClass: 'evaluation-result-dlg',
size: 'lg',
resolve: {
evaluationResult: function() {
return $scope.evaluationResult;
}
}
});
setupKeyHandling(modalInstance);
}
这里是我的控制器:
/**
* The controller for displaying evaluation results.
*/
annotatorApp.controller('EvaluationResultDialogCtrl', ['$scope', '$modal', '$modalInstance', '$http',
function ($scope, $modal, $modalInstance, $http, evaluationResult) {
$scope.trainingLog = {
text: ''
};
$scope.close = function() {
$modalInstance.close();
};
$scope.evaluationResult = evaluationResult; // Always undefined
}]);
有什么问题吗?
我看不到' 'evaluationResult''您的注入阵列内 - '[' $范围 ' '$模式',' $ modalInstance','$ http','。 –
@SlavaUtesinov是的,就是这样..我是AngularJS的新手..其实我只需要从另一个同事那里赶上一个项目。 ^^谢谢:) – displayname