1

I need to pass two parameter from typescript with angular.js to Controller. i tried this way but it didn't work. accutually i don't know that the way of i pass this parameters are correct

 IncrementDonation(donationId: number, donationAmount: number, successCallback: Function): void {
    this.httpService.put("/API/PrivateAPI/MyGivingPortfolio?donationId=" + donationId + "&donationAmount=" + donationAmount).success(function () {
        successCallback();
    });

}

values of donation Id and donation amount is passed from view.

This is my controller code.

 public bool Update(int donationId, decimal donationAmount)
    {
       // Some Code goes here

    }

2 Answers 2

1

After changing Controller Code like this it works fine. Thanks.. :D

public bool Put(int donationId, decimal donationAmount)
{
   // Some Code goes here

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

1 Comment

+1 but will give my answer below, as this is surely a coincidence that this works
1

Krishan,

I've noticed that you managed to get this working by using a method called Put. I have to confess (without trying), I cannot see how this will work as you reference a method called MyGivingPortfolio from your angular code. The method signature should (imho) be (notice i also qualify the http request type as [HttpPut]):

[HttpPut]
public ActionResult MyGivingPortfolio(int donationId, decimal donationAmount)
{
    // Some Code goes here
    // return appropriate json back to angular
}

Worth noting this as an alternative, in case you just lucked out with your approach above.

3 Comments

He is using webapi not mvc. He has incorrectly tagged the question. :)
ahhh - i see, tho i'm certain that my observation on the methodname holds true
BASarat Is Correct. :D

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.