Я хотел бы сравнить значения этих двух функций. К сожалению, я попытался сделать 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 Я отредактирую код, чтобы узнать, откуда они взялись! –