client/app/home/home_controller.js
author rougeronj
Thu, 02 Apr 2015 12:06:51 +0200
changeset 54 ccb586464a6f
parent 14 4d27fbc3f9df
child 55 10fd23382e76
permissions -rw-r--r--
clean js and minor update in html and css

(function(){
	'use strict';


	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){
		$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 '';
		};
	});

})();