如何比較在angularjs中的兩個不同函數中聲明的兩個不同的對象數組?
var app2 = angular.module("webApp2", [])
.controller("webCtrl2", function ($scope, $state, $http) {
console.log("hi");
$scope.username = $state.params.username;
console.log("shbsdjh" + $scope.email)
$scope.userId = $state.params.userid;
$scope.requests = [];
var addedList = [];
//Getting requests list:
$http.get("http://192.168.2.3:3000/userslist")
.then(function (response) {
console.log("hi", JSON.stringify(response));
$scope.requests = response.data;
}, function (response) {
console.log("error" + response);
});
$scope.addfrnd = function (reqname, index) {
console.log("shgsgh" + reqname);
var data = {
userId: $scope.userId,
requestname: reqname,
username: $scope.username
}
var req = {
method: 'POST',
url: 'http://192.168.2.3:3000/friendrequests',
data: data
}
$http(req).then(function (response) {
console.log("saghdha" + JSON.stringify(response.data));
//..........................................................................................
//Gettind added list
$http.get("http://192.168.2.3:3000/sendfriendrequests/" + $scope.username)
.then(function (response) {
console.log("added list" + JSON.stringify(response));
addedList = JSON.stringify(response.data.username);
console.log("addedlist" + addedList)
}, function (response) {
console.log("error" + response);
});
//..........................................................................................
}, function (response) {
console.log(response);
});
}
console.log("uname" + addedList);
$scope.logoutFn = function() {
$state.go("signup");
}
});
蔭與聊天application.Here蔭越來越userslist和使用APIs.In的userslist API發送請求列表的工作,人一個數組列表,將獲得和發送請求API,數組列表那些我發送請求的人將會出現。現在我必須比較這兩個包含對象的數組,以便將這些人移除到請求在userslist中發送的人.Iam在實現angularjs中的代碼時比較這些兩個數組聲明爲兩個不同的函數。請幫助我.. 這是我的javascript代碼:
你可以發表相同的代碼嗎? – Vivz
https://stackoverflow.com/questions/44698818/how-to-compare-two-arrays-which-are-in-different-functions/44699054#44699054 – Vivz