Fix error loading page when no contacts

This commit is contained in:
John Molakvoæ 2016-04-07 08:27:52 +02:00 committed by skjnldsv
parent e01603c4f5
commit f4602b37c1
1 changed files with 7 additions and 3 deletions

View File

@ -69,9 +69,13 @@ angular.module('contactsApp')
// Get contacts
ContactService.getAll().then(function(contacts) {
$scope.$apply(function() {
ctrl.contacts = contacts;
});
if(contacts.length>0) {
$scope.$apply(function() {
ctrl.contacts = contacts;
});
} else {
ctrl.loading = false;
}
});
// Wait for ctrl.contactList to be updated, load the first contact and kill the watch