--- a/client/app/home/home_controller.js Wed Mar 11 17:38:14 2015 +0100
+++ b/client/app/home/home_controller.js Tue Mar 17 16:34:23 2015 +0100
@@ -1,33 +1,40 @@
(function(){
- 'use strict';
+ 'use strict';
- angular.module('ammicoHome',['ngRoute'])
- .config(function ($routeProvider) {
- $routeProvider
- .when('/', {
- templateUrl: 'home/home.html',
- controller: 'homeCtrl'
- });
- })
- .controller('homeCtrl', function($scope, $location){
- console.log('5-0',$scope, $location);
- $scope.searchSubmit = function(){
- $location.path('/search/' + $scope.q);
- };
- })
- .filter('meta', function() {
- return function(input, metaName) {
- var nb = input.length, i = 0, found = false;
- while(found===false && i<nb){
- if(input[i].name===metaName){
- found = true;
- return input[i].value;
- }
- i++;
- }
- return '';
- };
- });
+ angular.module('ammicoHome',['ngRoute'])
+ .config(function ($routeProvider) {
+ $routeProvider
+ .when('/', {
+ templateUrl: 'home/home.html',
+ controller: 'homeCtrl'
+ });
+ })
+ .service('booksModel', function(searchApi) {
+ var _this = this;
+
+ this.books = searchApi.getResource.query({action:'books', format:'json'}, function(data){
+ _this.books = data;
+ });
+ })
+ .controller('homeCtrl', function($scope, $location, booksModel){
+ $scope.books = booksModel.books;
+ $scope.searchSubmit = function(){
+ $location.path('/search/' + $scope.q);
+ };
+ })
+ .filter('meta', function() {
+ return function(input, metaName) {
+ var nb = input.length, i = 0, found = false;
+ while(found===false && i<nb){
+ if(input[i].name===metaName){
+ found = true;
+ return input[i].value;
+ }
+ i++;
+ }
+ return '';
+ };
+ });
})();