dimanche 19 avril 2015

ng-click - after click do function and redirect

I have little problem.


I want to create ng-click with redirect, but before redirect I need to post some data.


My html code :



<a href="/test" ng-click="updateData($event)">Go</a>


My angular updateData function :



$scope.updateData = function($event){

$event.preventDefault();

$http.post(someAddress, $scope.data)
.success(function(){
// on success redirect
});
};


I found somethings like this scope.$eval(clickAction); but I don;t know how I should use it.


I can't use only redirect without JS because I have 2 different forms.


Aucun commentaire:

Enregistrer un commentaire