.controller('MainController',function($rootScope,$resource,BookService,CategoryService,Category){
var vm = this;
vm.category = new Category();
$rootScope.showCategoryInput = false;
function getCategories(){
vm.allCategories = CategoryService.getCategories();
}
getCategories();
function getAllBooks() {
vm.allBooks = BookService.getAllBooks();
}
getAllBooks();
vm.addCategory = function(){
if($rootScope.showCategoryInput === true){
CategoryService.addCategory(vm.category);
vm.category = new Category();
getCategories();
}
$rootScope.showCategoryInput = true;
}
})
Mam taki kontroler i chce żeby kategoria wyświetliła się od razu po dodaniu a tutaj wyświetla mi sie dopiero po dodaniu kolejnej