この2つの機能の値をvariable
と比較したいと思います。残念ながら私はvariables
global
を作りましたが、私はundefined
を得続けます。この2つの関数の値を比較するにはどうすればよいですか?
'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どこから来たのかを見るためにコードを編集します! –