如何比较在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