-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cria um GerenciadosDeListaDeTarefas para buscar todas ou uma por id
- Loading branch information
1 parent
18e5691
commit f51ed8c
Showing
4 changed files
with
57 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,17 @@ | ||
angular.module('app.controllers', []) | ||
|
||
.controller('MinhasListasCtrl', function($scope) { | ||
$scope.minhasListas = [ | ||
{ _id: '1', name: 'Lista de compras 1' }, | ||
{ _id: '2', name: 'Lista de compras 2' }, | ||
]; | ||
|
||
.controller('MinhasListasCtrl', function($scope, GerenciadorDeListasDeTarefas) { | ||
$scope.minhasListas = GerenciadorDeListasDeTarefas.buscarTodas() | ||
|
||
}) | ||
|
||
.controller('ListaDetalhesCtrl', function($scope, $stateParams) { | ||
// ^^^^^^^^^^^^ | ||
// $stateParams é um objeto que guarda os rótulos que vc definiu com ":" na definição de rota. | ||
// Hein!??! Explico: | ||
// Na linha 30 de routes.js a gente definiu a rota "/minhas-listas/:listaId", não foi? | ||
// Quando a url "/minhas-listas/123" for acessada o $stateParams.listaId vai retornar o valor "123"! | ||
// Fácil, né não?! ;) | ||
|
||
.controller('ListaDetalhesCtrl', function($scope, $stateParams, GerenciadorDeListasDeTarefas) { | ||
var idDaLista = $stateParams.listaId; | ||
// A gente vai usar esse "idDaLista" para recuperar a lista que queremos exibir os detalhes. | ||
var listaDeTarefas = GerenciadorDeListasDeTarefas.buscarPorId(idDaLista); | ||
|
||
// Torna a lista de tarefas que encontramos pelo id disponível para o HTML | ||
$scope.lista = listaDeTarefas; | ||
|
||
console.log("Lista de tarefas encontrada: ", listaDeTarefas); | ||
}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,7 @@ | ||
<ion-view title="Nome da Lista" id="page4" class=" "> | ||
<ion-view title="{{ lista.name }}" id="page4" class=" "> | ||
<!-- ^^^^^^^^^^^^^^^^ | ||
Ver controller.js#linha 13 | ||
--> | ||
<ion-content padding="true" class="has-header"> | ||
<ion-list id="nomeDaLista-list2" class=" "> | ||
<ion-item id="nomeDaLista-list-item8" class=" ">Item 1</ion-item> | ||
<ion-item id="nomeDaLista-list-item9" class=" ">Item 2</ion-item> | ||
<ion-item id="nomeDaLista-list-item10" class=" ">Item 3</ion-item> | ||
</ion-list> | ||
</ion-content> | ||
</ion-view> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters