You are on page 1of 3

.

controller('ibibliotecaCtrl', function($scope, bookService){


$scope.books = bookService.getBooks();
})

.controller('bookCtrl', function($scope, bookService, $stateParams){


var bookId = $stateParams.id;
$scope.book = bookService.getBook(bookId);
})

.factory('bookService', function() {
var books = [{
id:1,
title: 'Node JS',
year: '2014',
autor: 'CAIO RIBEIRO PEREIRA',
editorial: 'CASA DO CÓDIGO',
cover: 'Nodejs.jpg'
},
{
id:2,
title: 'Spring MVC',
year: '2015',
autor: 'ALBERTO SOUZA',
editorial: 'CASA DO CÓDIGO',
cover: 'Springmvc.jpg'
},
{
id:3,
title: 'Arduino Practico',
year: '2016',
autor: 'FERNANDO BRYAN FRIZZARIN',
editorial: 'CASA DO CÓDIGO',
cover: 'Arduino.jpg'
},
{
id:4,
title: 'Ionic Framework',
year: '2017',
autor: 'ADRIAN GOIS',
editorial: 'CASA DO CÓDIGO',
cover: 'Ionic.jpg'
},
{
id:5,
title: 'HTML5 Canvas',
year: '2014',
autor: 'ROQUE FERNANDO MARCOS SOUSA',
editorial: 'BRASPORT',
cover: 'html5.jpg'
}
];

return {
getBooks: function() {
return books;
},
getBook: function(id) {
return books[id];
},
}
})

.state('bookDetail', {
url: '/book/:id ',
templateUrl: 'templates/book.html',
controller: 'bookCtrl'
});
// Página por defecto
$urlRouterProvider.otherwise('/home');
})
<ion-view title="iBiblioteca">

<ion-content class="padding">

<ion-list>
<ion-item class="item item-text-wrap item-thumbnail-
left" ng-repeat="book in books" ui-sref="bookDetail({id: $index})">

<img src="img\{{book.cover}}">
<h2>{{book.title}}</h2>
Editorial: {{book.editorial}}<br>
</p>

</ion-item>

</ion-list>
</ion-content>
</ion-view>

You might also like