Answer the question
In order to leave comments, you need to log in
Why doesn't DI work?
There are 2 controllers.
app.controller("adminController", ["$scope", "$modal", "productsService", "ordersService", function ($scope, $modal, productsService, ordersService) {
......
$scope.openAddProductModal = function (size) {
var modalInstance = $modal.open({
templateUrl: '/modal/addproduct',
controller: 'addProductController',
size: size
});
modalInstance.result.then(function (selectedItem) {
$scope.selected = selectedItem;
});
};
}]);
app.controller('addProductController', ["$scope", "$modalInstance", "productsService", function ($scope, $modalInstance, productsService) {
$scope.ok = function () {
$modalInstance.close();
};
$scope.cancel = function () {
$modalInstance.dismiss('cancel');
};
}]);
Answer the question
In order to leave comments, you need to log in
Maybe because you declared the view controller twice? Well, that is, /modal/addproduct
there is something like in the file
and the controller is indicated in the open method. If so, then try to remove the directive ng-controller
from the view
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question