在这里我在每秒调用函数getData都很好,除了追加。每次函数调用angularjs时,都将旧数据替换为新数据。但是我想在现有数据之后追加。任何一个PLZ的帮助。
<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>
concat数据改为将其重新分配
像这样
$scope.LiveChat = $scope.LiveChat.concat(JSON.parse(myjson));
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句