Unknown provider: $confirmModalProvider <- $confirmModal <- confirmModalCtrl
注入錯誤,使用ui-bootstrap
爲什麼我得到這個錯誤?我正在嘗試使用AngularJS UI Bootstrap來打開模式並獲得結果。當我觸發$scope.deleteQuestion()
時,出現此錯誤。任何想法我在這裏做錯了嗎?
var crtPromoCtrl = angular.module('crtPromoCtrl', ['crtPromoSrv']);
crtPromoCtrl.controller('surveyCtrl', ['$scope', '$modal', 'surveySrv', function($scope, $modal, surveySrv)
{
$scope.questions = surveySrv.getQuestions();
$scope.editQuestion = function(index)
{
surveySrv.setEditQuestion(index);
};
$scope.deleteQuestion = function(index)
{
var confirmModal = $modal.open({
templateUrl: 'confirm-delete.html',
controller: 'confirmModalCtrl',
size: 'sm'
});
confirmModal.result.then(function(msg)
{
console.log(msg);
});
return false;
};
}]);
crtPromoCtrl.controller('confirmModalCtrl', ['$scope', '$confirmModal', function($scope, $confirmModal)
{
$scope.yes = function()
{
$confirmModal.close('yes');
};
$scope.no = function()
{
$confirmModal.dismiss('no');
};
}]);
編輯:https://angular-ui.github.io/bootstrap/#/modal
是什麼'$ confirmModal'的控制器?你想訪問'crtPromoCtrl'的confirmModal' –
請參閱腳本:https://angular-ui.github.io/bootstrap/#/modal。這就是我想要做的。 – jstudios
它是'$ confirmModal'還是'confirmModal'? –