AngularJS reload data in page without refresh












0















What i am doing is; i get the data from db and put it in



    $scope.GetMyData = function () {
//http get request here
.then(function (result) {
$scope.myData = result.data;
});
}


and when i want to refresh




$scope.myData




I have a function which is ticking every 15 seconds to trigger my GetMyData function to get the updated data. The timer function is like;



$interval(function () {
$scope.GetMyData();
}, 15000);


The problem is whenever I've overwritten $scope.myData, Page is not actually refreshing but the view looks like it's refreshed. Is there a way to solve this ?










share|improve this question

























  • after every call $scope.GetMyData you get updated data, so page has no reason to refresh, the view looks like it's refreshed because you get new data. Could you explain your problem exactly?

    – BartoszTermena
    Jan 2 at 9:25











  • @BartoszTermena ; It is somehow hard to explain but i'll try; I'm showing all user's data in page with ng-repeat, let's say there are 2 users in page and let one of the user's data changed. In the page for a second or less i am seeing 4 users (2 duplicated users). I guess DOM is not refreshing that fast.

    – devek om
    Jan 2 at 10:43


















0















What i am doing is; i get the data from db and put it in



    $scope.GetMyData = function () {
//http get request here
.then(function (result) {
$scope.myData = result.data;
});
}


and when i want to refresh




$scope.myData




I have a function which is ticking every 15 seconds to trigger my GetMyData function to get the updated data. The timer function is like;



$interval(function () {
$scope.GetMyData();
}, 15000);


The problem is whenever I've overwritten $scope.myData, Page is not actually refreshing but the view looks like it's refreshed. Is there a way to solve this ?










share|improve this question

























  • after every call $scope.GetMyData you get updated data, so page has no reason to refresh, the view looks like it's refreshed because you get new data. Could you explain your problem exactly?

    – BartoszTermena
    Jan 2 at 9:25











  • @BartoszTermena ; It is somehow hard to explain but i'll try; I'm showing all user's data in page with ng-repeat, let's say there are 2 users in page and let one of the user's data changed. In the page for a second or less i am seeing 4 users (2 duplicated users). I guess DOM is not refreshing that fast.

    – devek om
    Jan 2 at 10:43
















0












0








0








What i am doing is; i get the data from db and put it in



    $scope.GetMyData = function () {
//http get request here
.then(function (result) {
$scope.myData = result.data;
});
}


and when i want to refresh




$scope.myData




I have a function which is ticking every 15 seconds to trigger my GetMyData function to get the updated data. The timer function is like;



$interval(function () {
$scope.GetMyData();
}, 15000);


The problem is whenever I've overwritten $scope.myData, Page is not actually refreshing but the view looks like it's refreshed. Is there a way to solve this ?










share|improve this question
















What i am doing is; i get the data from db and put it in



    $scope.GetMyData = function () {
//http get request here
.then(function (result) {
$scope.myData = result.data;
});
}


and when i want to refresh




$scope.myData




I have a function which is ticking every 15 seconds to trigger my GetMyData function to get the updated data. The timer function is like;



$interval(function () {
$scope.GetMyData();
}, 15000);


The problem is whenever I've overwritten $scope.myData, Page is not actually refreshing but the view looks like it's refreshed. Is there a way to solve this ?







angularjs refresh livereload






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 2 at 10:44







devek om

















asked Jan 2 at 9:13









devek omdevek om

1013




1013













  • after every call $scope.GetMyData you get updated data, so page has no reason to refresh, the view looks like it's refreshed because you get new data. Could you explain your problem exactly?

    – BartoszTermena
    Jan 2 at 9:25











  • @BartoszTermena ; It is somehow hard to explain but i'll try; I'm showing all user's data in page with ng-repeat, let's say there are 2 users in page and let one of the user's data changed. In the page for a second or less i am seeing 4 users (2 duplicated users). I guess DOM is not refreshing that fast.

    – devek om
    Jan 2 at 10:43





















  • after every call $scope.GetMyData you get updated data, so page has no reason to refresh, the view looks like it's refreshed because you get new data. Could you explain your problem exactly?

    – BartoszTermena
    Jan 2 at 9:25











  • @BartoszTermena ; It is somehow hard to explain but i'll try; I'm showing all user's data in page with ng-repeat, let's say there are 2 users in page and let one of the user's data changed. In the page for a second or less i am seeing 4 users (2 duplicated users). I guess DOM is not refreshing that fast.

    – devek om
    Jan 2 at 10:43



















after every call $scope.GetMyData you get updated data, so page has no reason to refresh, the view looks like it's refreshed because you get new data. Could you explain your problem exactly?

– BartoszTermena
Jan 2 at 9:25





after every call $scope.GetMyData you get updated data, so page has no reason to refresh, the view looks like it's refreshed because you get new data. Could you explain your problem exactly?

– BartoszTermena
Jan 2 at 9:25













@BartoszTermena ; It is somehow hard to explain but i'll try; I'm showing all user's data in page with ng-repeat, let's say there are 2 users in page and let one of the user's data changed. In the page for a second or less i am seeing 4 users (2 duplicated users). I guess DOM is not refreshing that fast.

– devek om
Jan 2 at 10:43







@BartoszTermena ; It is somehow hard to explain but i'll try; I'm showing all user's data in page with ng-repeat, let's say there are 2 users in page and let one of the user's data changed. In the page for a second or less i am seeing 4 users (2 duplicated users). I guess DOM is not refreshing that fast.

– devek om
Jan 2 at 10:43














1 Answer
1






active

oldest

votes


















0














Use $watch service helps you to run some code when some value attached to the $scope has changed.



$scope.myData = "";

$scope.$watch('myData', function() {
/*Here you can bind changed value to your view, updated value can be reflected on $scope.myData change */
alert('myData has changed!');
});





share|improve this answer
























  • Thanks for your help but this is not what I'm looking for.

    – devek om
    Jan 2 at 10:45











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54003757%2fangularjs-reload-data-in-page-without-refresh%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Use $watch service helps you to run some code when some value attached to the $scope has changed.



$scope.myData = "";

$scope.$watch('myData', function() {
/*Here you can bind changed value to your view, updated value can be reflected on $scope.myData change */
alert('myData has changed!');
});





share|improve this answer
























  • Thanks for your help but this is not what I'm looking for.

    – devek om
    Jan 2 at 10:45
















0














Use $watch service helps you to run some code when some value attached to the $scope has changed.



$scope.myData = "";

$scope.$watch('myData', function() {
/*Here you can bind changed value to your view, updated value can be reflected on $scope.myData change */
alert('myData has changed!');
});





share|improve this answer
























  • Thanks for your help but this is not what I'm looking for.

    – devek om
    Jan 2 at 10:45














0












0








0







Use $watch service helps you to run some code when some value attached to the $scope has changed.



$scope.myData = "";

$scope.$watch('myData', function() {
/*Here you can bind changed value to your view, updated value can be reflected on $scope.myData change */
alert('myData has changed!');
});





share|improve this answer













Use $watch service helps you to run some code when some value attached to the $scope has changed.



$scope.myData = "";

$scope.$watch('myData', function() {
/*Here you can bind changed value to your view, updated value can be reflected on $scope.myData change */
alert('myData has changed!');
});






share|improve this answer












share|improve this answer



share|improve this answer










answered Jan 2 at 10:26









prasad07prasad07

213




213













  • Thanks for your help but this is not what I'm looking for.

    – devek om
    Jan 2 at 10:45



















  • Thanks for your help but this is not what I'm looking for.

    – devek om
    Jan 2 at 10:45

















Thanks for your help but this is not what I'm looking for.

– devek om
Jan 2 at 10:45





Thanks for your help but this is not what I'm looking for.

– devek om
Jan 2 at 10:45




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54003757%2fangularjs-reload-data-in-page-without-refresh%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Monofisismo

Angular Downloading a file using contenturl with Basic Authentication

Olmecas