diff --git a/app/css/app.css b/app/css/app.css index 43b8ecf..3d23f12 100644 --- a/app/css/app.css +++ b/app/css/app.css @@ -21,3 +21,59 @@ body { height: 115px; padding-top: 15px; } + +/** Detail View **/ +img.phone { + float: left; + border: 1px solid black; + margin-right: 3em; + margin-bottom: 2em; + background-color: white; + padding: 2em; + height: 400px; + width: 400px; +} + +ul.phone-thumbs { + margin: 0; + list-style: none; +} + +ul.phone-thumbs li { + border: 1px solid black; + display: inline-block; + margin: 1em; + background-color: white; +} + +ul.phone-thumbs img { + height: 100px; + width: 100px; + padding: 1em; +} + +ul.specs { + clear: both; + margin: 0; + padding: 0; + list-style: none; +} + +ul.specs > li{ + display: inline-block; + width: 200px; + vertical-align: top; +} + +ul.specs > li > span{ + font-weight: bold; + font-size: 1.2em; +} + +ul.specs dt { + font-weight: bold; +} + +h1 { + border-bottom: 1px solid gray; +} diff --git a/app/js/controladores.js b/app/js/controladores.js index 53af8db..d7a59ea 100644 --- a/app/js/controladores.js +++ b/app/js/controladores.js @@ -13,7 +13,9 @@ phonecatControladores.controller('ListaTelefonosCtrl', ['$scope', '$http', $scope.ordenProp = 'age'; }]); -phonecatControladores.controller('DetallesTelefonoCtrl', ['$scope', '$routeParams', - function($scope, $routeParams) { - $scope.idTelefono = $routeParams.idTelefono; +phonecatControladores.controller('DetallesTelefonoCtrl', ['$scope', '$routeParams', '$http', + function($scope, $routeParams, $http) { + $http.get('phones/' + $routeParams.idTelefono + '.json').success(function(data) { + $scope.telefono = data; + }); }]); \ No newline at end of file diff --git a/app/partials/detalle-telefono.html b/app/partials/detalle-telefono.html index a69422a..a4e9783 100644 --- a/app/partials/detalle-telefono.html +++ b/app/partials/detalle-telefono.html @@ -1 +1,113 @@ -TBD: vista detalle para {{idTelefono}} + + +

{{telefono.name}}

+ +

{{telefono.description}}

+ + + + diff --git a/test/unit/controladoresSpec.js b/test/unit/controladoresSpec.js index fe4598f..7a693f7 100644 --- a/test/unit/controladoresSpec.js +++ b/test/unit/controladoresSpec.js @@ -29,4 +29,26 @@ describe('controllers', function() { expect(scope.ordenProp).toBe('age'); }); + describe('DetallesTelefonoCtrl', function(){ + var scope, $httpBackend, ctrl; + + beforeEach(inject(function(_$httpBackend_, $rootScope, $routeParams, $controller) { + $httpBackend = _$httpBackend_; + $httpBackend.expectGET('phones/xyz.json').respond({name:'telefono xyz'}); + + $routeParams.idTelefono = 'xyz'; + scope = $rootScope.$new(); + ctrl = $controller('DetallesTelefonoCtrl', {$scope: scope}); + })); + + + it('debe obtener el detalle de un teléfono', function() { + expect(scope.telefono).toBeUndefined(); + $httpBackend.flush(); + + expect(scope.telefono).toEqual({name:'telefono xyz'}); + }); + }); + + });