How can I open a modal inside of a modal? Ive followed this plnkr but I got an error when I click the confirm button of the second modal. This is the error:
Error: [$injector:unpr]
This is my first modal
$scope.edit = function(data) {
var modalInstance = $uibModal.open({
templateUrl: "/wp-content/themes/copywriter-theme/angular-modal-template/management_modal.html",
controller: 'managementModal',
resolve: {
items: function() {
return data;
}
}
});
}
This is my 2nd modal
angular.module(['ui.bootstrap']).controller('managementModal',['$scope','$http','$uibModalInstance','$uibModal','items',function($scope, $http, $uibModalInstance, $uibModal, items){
$scope.names = items;
$scope.editable = items;
$scope.cancel = function(){
$uibModalInstance.dismiss('cancel');
location.reload();
};
$scope.confirm = function(){
console.log("clicked");
$uibModalInstance.close($scope.editable);
}
$scope.update = function(){
var template_modal = "<div class='modal-body'>" +
"<button type='button' class='close' ng-click='confirm()'>update</button>" +
"<button type='button' class='close' ng-click='cancel()'>cancel</button>" +
"</div>";
var modalInstance = $uibModal.open({
template: template_modal,
controller: 'managementModal'
});
};
}]);
So the first modal is in another controller while the second modal is inside of the controller managementModal. But in plnkr its okay to click the button and its working I dont know why my button on my second modal are not working