我想比较这两个函数的variable
值。不幸的是,我试图使variables
global
但我不断得到undefined
。如何比较这两个函数之间的值?
'use strict';
/**
* @ngdoc function
* @name dashyAppApp.controller:Dashy3Ctrl
* @description
* # Dashy3Ctrl
* Controller of the dashyAppApp
*/
angular.module('dashyAppApp')
.controller('Dashy3Ctrl', function ($rootScope, $scope, employees, $interval) {
var _this = this;
$scope.getData = function() { // getDATA function
employees.getEmployees().then(function(response){
_this.items = response.data;
$scope.items = _this.items;
callmecrazy(response.data);
});
}// End getDATA function
$scope.getData();
$scope.getDataB = function() {
employees.getEmployees().then(function(response){
_this.items = response.data;
callmecrazier(response.data);
});
}
$interval(function(){
$scope.getDataB();
}, 10000);
function callmecrazier(response1){
callmecrazierVal = response1.countries;
return callmecrazierVal;
}
function callmecrazy(response){
callmecrazyVal = response.countries;
return callmecrazyVal;
}
if(!angular.equals(callmecrazierVal(), callmecrazyVal())) {
//trigger some other function
}
});
我想检查是否callmecrazierVal !== callmecrazyVal
。这是我上面完整的controller
代码。
if(callmecrazierVal !== callmecrazyVal){
//trigger some other function
}
'var'使它们本地,如果你想他们全球删除它。你也可以使用'return'而不是控制台日志,然后比较函数调用。 –
这些回应来自哪里? – Bergi
@Bergi我将编辑代码以查看它们来自哪里! –