2014-11-26 3 views
0

캔버스 항목을 클릭하여 부트 스트랩 모달을 열어 놓은 웹 사이트에 angularjs를 사용하려고합니다. 지금까지는 모달을 제외하고는 다른 모든 작업을했습니다. 항목을 클릭하면 오류가 발생합니다. TypeError : 정의되지 않은 'open'속성을 읽을 수 없습니다.

오픈이 올바르게 호출되지 않는 이유를 알 수있는 사람이 있습니까? 고맙습니다.

app.controller('contentModalCtrlr', ['$scope', function($scope, $modal) { 
$scope.opened = ''; 

$scope.open = function (template) { 
    consloe.log(template); 
    var modalInstance = $modal.open({ 
     templateUrl: template, 
     controller: 'ModalInstanceCtrlr', 
     size: 'lg' 
    }); 
}; 

$scope.$watch('opened', function(newValue, oldValue) { 
    console.log(newValue,oldValue); 

    if (newValue == 'spellcards') { 
     console.log('Open a Spell Card Modal!'); 
     $scope.open('spellcards.html'); 
    } 
    else if (newValue == 'monstercards') { 
    console.log('Open a Monster Card Modal!'); 
    $scope.open('monstercards.html'); 
} 
}); 
console.log($scope); 
}]); 

app.controller('ModalInstanceCtrl', function ($scope, $modalInstance) { 
    $scope.ok = function() { 
    $modalInstance.close(); 
    }; 

    $scope.cancel = function() { 
    $modalInstance.dismiss('cancel'); 
    }; 
}); 

답변

1

오타 오류 :

app.controller('ModalInstanceCtrl', function ($scope, $modalInstance) { 

WORKING EXAMPLE

+0

@d :

var modalInstance = $modal.open({ templateUrl: template, controller: 'ModalInstanceCtrlr', // <-- extra 'r' size: 'lg' }); 

controller: 'ModalInstanceCtrl', 

주이어야한다 eadpickle는 나의 편집을 본다. 지난 밤에 나는 거의 피곤하지 않았다. 그리고 나의 대답은 틀렸다. 지금 고쳐. –

+0

맞아.하지만 내 contentModalCtrlr에 $ modal을 전달하는 걸 잊었다. – deadpickle