javascript - AngularJS scope no updating -


i'm using button invokes clickloadmoreposts has 2 parameters, important 1 date, button triggers function below.

in response, i'm receiving javascript code update date in button's parameter , it's updating fine, when click again button, scope taking first date, instead date got in response when new date updated in html code (i looked through google chrome inspector).

i think problem because $scope not updating new content , therefore not taking new date.

i read should use $apply in place, got error because $http uses $apply.

help , insight appreciated!

html

<span id="loadmoreposts" ng-click="clickloadmoreposts({{$idaccount}},'{{$date}}')"> load more content </span> 

javascript

function todoctrl($scope, $http ) {      $scope.clickloadmoreposts = function(idaccount, date) {        $http.post("loadpersonalposts", {'idaccount': idaccount, 'date': date} )         .success(function (data) {             $('#postloader').append(data);         }).error(function (data) {             alert("error");       });     }; } 

you should assign response data scope variable, in page, should use {$scope.data. date} rather manipulating dom via append.


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -