Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I am trying to update my angular model using a known working webmethod (.net).

  • I get data back from my webmethod logged to the console successfully.

  • It updates the text-box value as well.

  • But this doesn't update my angular model binding.

What am I doing wrong?

HTML

 <input class="txtCalls" ng-model="TotalCalls"/>

Angular

$scope.TotalCalls;

CodeBehind

    [WebMethod]
    [ScriptMethod(UseHttpGet = true]
    public static string GetCallData()
    {
         String Calls = "34";
         return Calls;
    }

Ajax Call

$(document).ready(function () {
            $('.btn-primary').click(function () {
                $.ajax({
                    type: "GET",
                    url: "Stats.aspx/GetCallData",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function (response) {
                        $('.txtCalls').text(response.d);
                        console.log(response.d);
                    },

                    failure: function (response) {
                        alert(response.d);
                        console.log(response.d);
                    }
                });
             });
share
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.