displayname displayname - 1 year ago 57
AngularJS Question

Why is this parameter for modal is always undefined?

I am trying to pass values to a modal over parameters. For some reason this parameter is always

when I try to access it in my controller. The second answer of this question is what I am building upon.

Here is my setup for the modal. Please note that
is defined and has valid content.

$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;

Here is my controller:

* 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 () {

$scope.evaluationResult = evaluationResult; // Always undefined


What is the problem here?

Answer Source

You forgot to put it in injection array, should be:

annotatorApp.controller('EvaluationResultDialogCtrl', ['$scope', '$modal', '$modalInstance', '$http', 'evaluationResult', function ($scope, $modal, $modalInstance, $http, evaluationResult) {

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download