I m trying to use a controller callback function inside my service, when it successes an $http post request. Here's my code, the exact description is a bit below.
my controller :
function UserAccountCtrl (UserService, $rootScope, listUsers) {
    $rootScope.title = 'Comptes utilisateurs';
    this.users = listUsers.data;
  this.isShown = false;
  this.isModification = false;
    this.deleteEntry = function(entry){
    this.users.splice(this.users.indexOf(entry), 1);
    UserService.delete(entry); 
  };
  this.show = function(){
    this.isShown = true;
  };
  this.hide = function(){
    this.isShown = false;
  };
  this.save = function(){
    var success = function(data){
      this.users.push(data);
    };
    var err = function(data){
      alert(data);
    };
    UserService.post(this.user, success, err);
    this.hide();
  };
}
My service function :
UserService.post = function (data,succ,err) {
    $http({
        url: __ADRS_SRV__ + "user",
        method: "POST",
        data:data,
        isArray: true
    }).success(function(data){
       succ(data);
    }).error(function(error){
        err(error);
    });
}
The functionnement is simple : when I post a new user, the WebService inserts it in mongo, and returns the fully new object generated. I can get the new object from console.log or with an alert, and it works fine.
But I cant push the new item in my array. I have the error :
Uncaught TypeError: undefined is not a function
At the exact line where I need to push the new item.
So, does anybody have an idea ?
Thanks for advance
 
     
     
    