The modal of the Angular UI will report the following error when written in the official documentation
var modaldemoctrl = function ($scope, $modal, $log) { $ scope.items = [' item1 ', ' item2 ', ' item3 ']; $scope. open = function (size) { var modalInstance = $modal. Open ({ templateUrl: ' mymodalcontent.html ', controller: ModalInstanceCtrl, size: size, resolve: { items: function () { return $scope .items; } } }); ModalInstance.result.then (function (SelectedItem) { $ Scope.selected = selecteditem; }, function () { $log. info (' modal dismissed at: ' + new date ()); }); };};/ / please note that $modalInstance represents a modal window ( Instance) dependency.// It is not the same as the $modal service used above.var modalinstancectrl = function ($scope, $modalInstance , items) { $scope .items = items; $scope .selected = { item: $scope .items[0] }; $scope .ok = function () { $modalInstance. Close ($scope. Selected.item); }; $ scope.cancel = function () { $modalInstance. Dismiss (' Cancel '); };};
[$injector: UNPR] Unknown provider: $modalInstanceProvider <-$modalInstance
Google a bit, found that the official has reported a bug
#1549
The official explanation is:
The problem was, were specifying a controller in 2 Places-when opening a modal and inside a template-this is n OT needed. Remove Ng-controller from a template and things would work as expected:
Originally, in writing modal option when the controller has been developed, there is no need to add Ng-controller in the template to make a controller