MY code is like this
Controller.JS
angular.module('RateRequestApp.controllers', []).controller('ReadOnlyController', function($scope, rateRequestService) {
$scope.rateData = [];
rateRequestService.getData().success(function(response) {
$scope.rateData = response;
}).error(function (data, status, headers, config) {
$scope.openModal();
});
});
angular.module('RateRequestApp.controllers').controller('ModalDemoCtrl', function($scope, $modal, $log) {
$scope.openModal = function(size) {
var modalInstance = $modal.open({
templateUrl: 'myModalContent.html',
controller: 'ModalInstanceCtrl',
size: size,
});
};
});
App.JS
angular.module('RateRequestApp', [
'RateRequestApp.services',
'RateRequestApp.controllers',
'ui.bootstrap'
]);
As you can see I am trying to call a function $scope.openModal();
inside another controller, And obviously it throws an error
TypeError: undefined is not a function
at line
$scope.openModal();
Is there any way to overcome this issue?