There seems to be a confusion with the functionality not working as expected:
In my Angular application, I have a main page with an ng-controller named "SearchCtrl" that handles sending search requests to a webserver.
app.controller('SearchCtrl', ['$http','$scope', function($http,$scope) {
$scope.doAlert = function() {
console.log('search page alert inside searchresultsctrl');
}
This SearchCtrl is utilized on my search page and further down the page, there is another controller called SearchSortModalCtrl which triggers a modal for user interactions:
app.controller('SearchSortModalCtrl', function ($scope, $modal, $log) {
.....
var modalInstance = $modal.open({
templateUrl: '/modal-search-sort.html',
controller: 'SearchSortFormCtrl',
size: size,
resolve: {
items: function () {
return $scope.items;
}
}
});
This connects to the SearchSortFormCtrl which has:
app.controller('SearchSortFormCtrl', ['$http','$scope','$rootScope','$modalInstance', function($http,$scope,$rootScope,$modalInstance) {
$scope.cancel = function () {
$modalInstance.dismiss();
};
$scope.doAlert2 = function() {
console.log('search page alert test2');
}
The goal is to trigger an action on SearchCtrl when submitting a form within the modal window. However, using ng-submit="doAlert()" does not work as intended. Changing it to doAlert2() functions correctly in SearchSortFormCtrl. Even attempting ng-submit="$parent.doAlert()" or "$parent.$parent.doAlert()" did not yield the desired outcome.
What could be causing this issue, or how can I execute actions within SearchCtrl from the modal form?