0

Html page code:

ng-click="removeCoupon(coupon.couponId)"

controller:

$scope.removeCoupon=adminService.removeCoupon(Id)
  .then(
            function(response) {
                hide_all_and_show_one_insideTab( 'successLog');
          $scope.log = "Coupon Id# " + Id + " successfully removed.";
            adminService.getCoupons()
        .then(
            function(response) {
                $scope.coupons = response.data;
            } );

            } );`

service:

     this.removeCoupon = function(Id){
     return $http.get(baseURL+"admin/removeCoupon/"+Id);
                                };

when i load the html, there is an eror "angular.js:13424ReferenceError: Id is not defined at new (controller1.js:56)"

Someone can point my eror? before i did it without service and it worked just fine, so the ng-click successfuly transfer the coupon.couponId, now when i try to transfer all the server calling to a service, i get this eror. the controller1 js.56 is the 1st line of the controler code i wrote here.

1 Answer 1

2

You have to do it like this

$scope.removeCoupon = function(Id){
   adminService.removeCoupon(Id)
     .then(
            function(response) {
                hide_all_and_show_one_insideTab( 'successLog');
             $scope.log = "Coupon Id# " + Id + " successfully removed.";
               adminService.getCoupons()
          .then(
              function(response) {
                  $scope.coupons = response.data;
              } );

             } );
}
Sign up to request clarification or add additional context in comments.

2 Comments

what do you mean? how do i do that?
There is a grey check icon below vote-up option please click on it

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.