0

In my main page there is a div id="page_content", i load a jsp page in that div. and there is a refresh button ,through which the page is reloaded in that div. i have written some angularjs like {{1+2}} on that page. first it run properly displaying result 3. but when refresh button is clicked calling $('#page_content').load(page_url); page is refreshed but my angularjs func gone and it displayed {{1+2}}. how to overcome through this?

i tried route functionality but it dosen't work

angular.module('div', [])
.controller('divcontroller', ['$scope', function ($scope,$location)
{
    $scope.ConfirmRefresh = function(){   
        $('#page_content').load(page_url);
    }
}]);


angular.element(function()
{
    angular.bootstrap(document, ['div']);
});

after refresh button is clicked page should be loaded with angular js .

georgeawg
  • 48,608
  • 13
  • 72
  • 95
snljais
  • 1
  • 4

2 Answers2

0

I believe this is an issue with the function caching data for when its called the next time, however it caches the code not the resulting code.

Consider using : $window.location.reload()

this should refresh the page completely

Tom Edwards
  • 124
  • 1
  • 13
0
Thank you @Mark Schultheiss and @Tom Edwards 

I make refresh directive and call on click event with compile and it works for me

.directive('refreshConfirm', function($http,$compile) {
        return {
            restrict: 'A',
            link: function postLink(scope, element, attrs) {
                element.bind('click', function () {

                    $http.get(page_url).then(successCallback, errorCallback);
                    function successCallback(response){
                        //success code
                        var ty=response.data;
                        var appi=angular.element(document.querySelector('#page_content')).html($compile(ty)(scope));
                    }
                    function errorCallback(error){
                        //error code
                        alert('error');
                    }                       

                });
            }
        };
    })
snljais
  • 1
  • 4