How to call AngularJS function after partial postback in asp.net?

705 Views Asked by At

How to call AngularJS function after partial postback (from ascx page) in ASP.Net inside an UpdatePanel. Initially I call angular function on ng-init. But after the partial postback, the function is not called. How could I call the function?

Function name is BindLeadGridHeader. Here is my Angular JS code:

.controller('CtrlSalesNav', ['$scope', '$http', '$location', '$timeout', function ($scope, $http, $location, $timeout) {
           //function for Bind Module Name Drop Down Created By :Prashant Kumar OnDate:21.04.2017  
           var UserId = sessionStorage.CurrentUserId;
           var CurrentModuleName = 'Lead';
           $scope.AllHeader = '';
           //code for bind all header to table 
           $scope.BindLeadGridHeader = function () {
               $http.get(WebApiUrl + "api/GetAllLeadHeader?UserId=" + UserId + "&ModuleName=" + CurrentModuleName).then(function (response) {
                   alert('Header bind call');
                   $scope.AllHeader = response.data.Table;

Calling code on ascx page inside UpdatePanel:

  <div class="lead_noTopMenu" id="divLeadGrid" ng-controller="CtrlSalesNav" ng-cloak>
            <div class="row" style="margin-top: 90px;" data-ng-init="BindLeadGridHeader();">
                <!-- Search FORM-->
                <div class="row row1" id="search" style="display: none;">
                    <div class="col-md-12">
                        <div class="tabbable tabbable-custom">
                            <ul class="nav nav-tabs">
1

There are 1 best solutions below

0
Mike Feltman On

You probably should be using an angular directive or component. There's a 3rd callback on promises that's rarely used, called notify, that might work for you. It's called while the promise is waiting to be resolved.