I have a controller where I define a function along with it's template. It is a modal that needs to pop-up. No modal pops up and access denied for mymodal.html.
My controller/app:
angular.module('myApp').controller('MyCtrl',function (
...
...
...
$scope.removeComment = function (reply) {
var myModalInstance = $modal.open({
scope: $scope,
templateUrl: 'mymodal.html',
controller: function ($scope, $modalInstance, reply) {
in the template I am including:
<div ng-app="myApp" ng-controller='MyCtrl'>
What can be wrong?
I think problem is in your controller
function: reply
is not defined, i suppose. If you will open console, i think you will see something like this:
Error: [$injector:unpr] Unknown provider: replyProvider <- reply
If you want to inject something into your controller, you can write some service.
BTW, if you are going to use some minificator you will see errors, because when you define controller
by this way and minificate your code - your injections will be minificated too.
Better way is to do something like this:
var app = angular.module('app', ['ui.bootstrap']);
app.controller('MyCtrl', ['$scope', '$modal', function ($scope, $modal) {
$scope.removeComment = function (reply) {
var myModalInstance = $modal.open({
scope: $scope,
templateUrl: 'mymodal.html',
controller: 'modalController',
...
});
};
/* SOME CODE HERE */
}]);
and
app.controller('modalController', ['$scope', '$modalInstance', function ($scope, $modalInstance) {
/* SOME LOGIC HERE */
}]);
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments