Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
templates cached, implemented filter
- Loading branch information
1 parent
e68b922
commit 2de5ef0
Showing
8 changed files
with
90 additions
and
15 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,2 +1,3 @@ | ||
asset 'angular' | ||
asset 'bootstrap-sass-official' | ||
asset 'angular-route' |
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
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,3 +1,44 @@ | ||
receta = angular.module('receta', [ | ||
receta = angular.module('receta',[ | ||
'templates', | ||
'ngRoute', | ||
'controllers', | ||
]) | ||
|
||
receta.config([ '$routeProvider', | ||
($routeProvider)-> | ||
$routeProvider | ||
.when('/', | ||
templateUrl: "index.html" | ||
controller: 'RecipesController' | ||
) | ||
]) | ||
|
||
recipes = [ | ||
{ | ||
id: 1 | ||
name: 'Baked Potato w/ Cheese' | ||
}, | ||
{ | ||
id: 2 | ||
name: 'Garlic Mashed Potatoes', | ||
}, | ||
{ | ||
id: 3 | ||
name: 'Potatoes Au Gratin', | ||
}, | ||
{ | ||
id: 4 | ||
name: 'Baked Brussel Sprouts', | ||
}, | ||
] | ||
controllers = angular.module('controllers',[]) | ||
controllers.controller("RecipesController", [ '$scope', '$routeParams', '$location', | ||
($scope,$routeParams,$location)-> | ||
$scope.search = (keywords)-> $location.path("/").search('keywords',keywords) | ||
|
||
if $routeParams.keywords | ||
keywords = $routeParams.keywords.toLowerCase() | ||
$scope.recipes = recipes.filter (recipe)-> recipe.name.toLowerCase().indexOf(keywords) != -1 | ||
else | ||
$scope.recipes = [] | ||
]) |
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<header class="row"> | ||
<h1 class="text-center col-md-6 col-md-offset-3">Find Recipes</h1> | ||
</header> | ||
<section class="row"> | ||
<form> | ||
<div class="form-group col-md-6 col-md-offset-3"> | ||
<label for="keywords" class="sr-only">Keywords</label> | ||
<input ng-model="keywords" name="keywords" type="text" autofocus class="form-control" placeholder="Recipe name, e.g. Baked Potato"> | ||
|
||
</div> | ||
<div class="form-group col-md-6 col-md-offset-3 text-center"> | ||
<button ng-click="search(keywords)" class="btn btn-primary btn-lg">Search</button> | ||
|
||
</div> | ||
</form> | ||
</section> | ||
<hr> | ||
<section class="row" ng-if="recipes"> | ||
|
||
<h1 class="text-center h2">Results</h1> | ||
<ul class="list-unstyled"> | ||
<li ng-repeat="recipe in recipes"> | ||
<section class="well col-md-6 col-md-offset-3"> | ||
<h1 class="h3 col-md-6 text-right" style="margin-top: 0"><a href="#">{{recipe.name}}</a></h1> | ||
<div class="col-md-6"> | ||
<button class="btn btn-info">Edit</button> | ||
<button class="btn btn-danger">Delete</button> | ||
</div> | ||
</section> | ||
</li> | ||
</ul> | ||
</section> |
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,14 +1,5 @@ | ||
<div class="container-fluid" ng-app="receta"> | ||
<div class="panel panel-success"> | ||
<div class="panel-heading"> | ||
<h1 ng-if="name">Hello, {{name}}</h1> | ||
</div> | ||
<div class="panel-body"> | ||
<form class="form-inline"> | ||
<div class="form-group"> | ||
<input class="form-control" type="text" placeholder="Enter your name" autofocus ng-model="name"> | ||
</div> | ||
</form> | ||
</div> | ||
<div ng-app="receta"> | ||
<div class="view-container"> | ||
<div ng-view class="view-frame animate-view"></div> | ||
</div> | ||
</div> |
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