Created
October 28, 2015 07:50
-
-
Save anaumov/726d46ec26cc13ee07b7 to your computer and use it in GitHub Desktop.
Использование промисов
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function loadCountries(){ | |
$http.get('http://api.com/countries') | |
} | |
var allCountries = []; | |
// летит запрос на сервер, ждем ответа, после ответа заполняем массив | |
loadCountries().then(function(data){ | |
allCountries = data.countries | |
}) | |
// запрос на серве не летит, не надо ждать ответа, данные появляются мнговенно | |
setTimeout(function(){ | |
loadCountries().then(function(data){ | |
console.log(data.countries); | |
}) | |
}, 60000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment