Skip to content

Commit 78e6e1b

Browse files
author
Erick Leandro
committed
Level 4 complete
1 parent 20aa33b commit 78e6e1b

File tree

6 files changed

+142
-1
lines changed

6 files changed

+142
-1
lines changed

js/app.js

+41-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,41 @@
1-
var app = angular.module('store', []);
1+
'use strict';
2+
var app = angular.module('store', []);
3+
4+
app.directive('productTitle', function(){
5+
6+
return {
7+
8+
restrict: 'E',
9+
templateUrl: 'product-title.html'
10+
11+
};
12+
13+
});
14+
15+
app.controller('StoreController', ['$scope', function($scope){
16+
17+
var products = [
18+
{
19+
20+
name: 'Mouse and Keyboard Wireless',
21+
price: '150,00',
22+
description: 'Nice product',
23+
images: [],
24+
reviews: [
25+
{
26+
stars: 5,
27+
body: 'I love this product',
28+
author: 'Cristiano ronaldo',
29+
},
30+
{
31+
stars: 1,
32+
body: 'This product sucks',
33+
author: 'Lionel Messi',
34+
}
35+
]
36+
}
37+
];
38+
39+
$scope.products = products;
40+
41+
}]);

leve3.html

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<html ng-app="store">
2+
<head>
3+
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" />
4+
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.1/angular.min.js"></script>
5+
<script src="js/app.js"></script>
6+
</head>
7+
<body ng-controller="StoreController as store">
8+
<ul class="list-group">
9+
<li class="list-group-item" ng-repeat="product in store.products | orderBy: '-price' ">
10+
11+
<div class="panel" ng-show="panel.isSelected(3)">
12+
<h4>Reviews</h4>
13+
<blockquote ng-repeat="review in product.reviews">
14+
15+
<b>Stars: {{ review.stars }}</b>
16+
{{ review.body }}
17+
<cite>{{ review.author }}</cite>
18+
</blockquote>
19+
</div>
20+
</li>
21+
</ul>
22+
</body>
23+
</html>

level3.1.html

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<html ng-app="store">
2+
<head>
3+
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" />
4+
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.19/angular.min.js"></script>
5+
<script src="js/app.js"></script>
6+
</head>
7+
<body ng-controller="StoreController">
8+
<form name="reviewForm">
9+
10+
<blockquote>
11+
12+
<b>Stars: {{ review.stars }}</b>
13+
{{ review.body }}
14+
<cite>{{ review.author }}</cite>
15+
</blockquote>
16+
17+
<select ng-model="review.stars">
18+
<option value="1">1 Stars</option>
19+
<option value="2">2 Stars</option>
20+
<option value="3">3 Stars</option>
21+
<option value="4">4 Stars</option>
22+
<option value="5">5 Stars</option>
23+
</select>
24+
25+
<textarea ng-model="review.body"></textarea>
26+
27+
<label>By: </label>
28+
<input ng-model="review.author" type="text" />
29+
<input type="submit">
30+
</form>
31+
32+
</body>
33+
</html>

level3.html

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<html ng-app="store">
2+
<head>
3+
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" />
4+
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.19/angular.min.js"></script>
5+
<script src="js/app.js"></script>
6+
</head>
7+
<body ng-controller="StoreController">
8+
<ul class="list-group">
9+
<li class="list-group-item" ng-repeat="product in products | orderBy: '-price' ">
10+
11+
<div class="panel">
12+
<h4>Reviews</h4>
13+
<blockquote ng-repeat="review in product.reviews">
14+
15+
<b>Stars: {{ review.stars }}</b>
16+
{{ review.body }}
17+
<cite>{{ review.author }}</cite>
18+
</blockquote>
19+
</div>
20+
21+
</li>
22+
</ul>
23+
</body>
24+
</html>

level4.html

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<html ng-app="store">
2+
<head>
3+
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" />
4+
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.19/angular.min.js"></script>
5+
<script src="js/app.js"></script>
6+
</head>
7+
<body ng-controller="StoreController">
8+
<ul class="list-group">
9+
<li class="list-group-item" ng-repeat="product in store.products | orderBy: '-price' ">
10+
<product-title></product-title>
11+
</li>
12+
</ul>
13+
</body>
14+
</html>

product-title.html

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<h3>
2+
3+
{{ product.name }}
4+
5+
<em class="pull-right">${{ product.price }} </em>
6+
7+
</h3>

0 commit comments

Comments
 (0)