0

I have the following AngularJS function called editlocation that opens a Modal window that I can edit three pieces of data.

After the result I want to be able to run plotmarkers this is used in another instance of an ng-click. I have tried the following but it doesn't work. I also tried placing it inside the ModalInstanceCtrl2 controller too, but no luck.

$scope.editlocation = function (locations) {
    var locationToEdit = locations; 
    var modalInstance = $modal.open({
        templateUrl: 'template/modal-edit-marker.html',
        controller: ModalInstanceCtrl2,
        resolve: {
            locations: function () {
                return locationToEdit;
            }
        },
        scope: $scope.$new()
    });
    modalInstance.result.then(function (selectedItem) {
    locationToEdit.title = selectedItem.title;
    locationToEdit.gps = selectedItem.gps;
    locationToEdit.desc = selectedItem.desc;
    $scope.plotmarkers;
    }, function () {
        console.log('Modal dismissed at: ' + new Date());
    });
};


$scope.plotmarkers = function() {
    //things will happen here
};

2 Answers 2

1

You aren't actually calling the function here. Try this:

$scope.plotmarkers();
Sign up to request clarification or add additional context in comments.

Comments

0

Unless plotmarkers in in the same controller/scope (ModalInstanceCtrl2) you are calling it that won't work. a far better approach would be to emit or broadcast an event that would let know every interested party that markers should be plotted you can do it either using the controllers scope or the $rootScope if you have it injected.

1 Comment

excuse me why was i down voted here? whats wrong with my answer? if someone could please educate me in what is wrong with my method, we might all learn something in the process

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.