When a websocket message recieved the following code runs:
connection.onmessage = function (eventInfo) {
var onConnectionMessage = JSON.parse(eventInfo.data);
if (onConnectionMessage.messageType === "newRequest") {
getQuizRequests();
}
}
getQuizRequests() is the following function:
function getQuizRequests() {
var URL = '/acceptOrReject/' + lookUpCode();
$http.get(URL)
.success(function (data) {
for (var i = 0; i < data.teamArray.length; i++) {
teamArray[0] = data.teamArray[i];
}
})
.error(function (data, status) {
alert("ERROR data cant be loaded");
});
}
I want to call this teamArray in a ng-repeat. How can I send this array filled to the code where I use ng-repeat?
Assuming this is all in the same controller
$scope.teamArray = [];
function getQuizRequests() {
var URL = '/acceptOrReject/' + lookUpCode();
$http.get(URL)
.success(function (data) {
for (var i = 0; i < data.teamArray.length; i++) {
$scope.teamArray.push(data.teamArray[i]);
}
})
.error(function (data, status) {
alert("ERROR data cant be loaded");
});
}
Then in your html
<ul ng-show="teamArray.length > 0" ng-repeat="member in teamArray">
<li>{{member}}</li>
</ul>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.