Here i am calling function getData at every second all is happning good except appending. every time when function is calling the angularjs is replacing old data to new data. but i want to append after existing data. any one plz help.
<div ng-app="serviceConsumer">
<div ng-controller="questionsController">
<div ng-repeat="j in LiveChat">
<div>
<div>{{j.UserName2}}</div>
<div>
<div>{{j.Text2}}<div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
var app = angular.module('serviceConsumer', []);
app.controller('questionsController', function ($scope, $http) {
$scope.getData = function () {
$http({
method: "GET",
url: "/GetUserDataWebServices.asmx/GetLiveChatListData",
params: {
username: $('.ExeCutiveName').text()
}
})
.success(function (data) {
var myjson = JSON.parse(data);
$scope.LiveChat = JSON.parse(myjson);
//here i want to append myjson to existing ng-repeat <div>
});
}
)};
setInterval($scope.getData, 1000);
</script>
You need to use push method
like $scope.LiveChat.push(JSON.parse(myjson));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With