-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finish components, ready for course 2
- Loading branch information
Showing
11 changed files
with
121 additions
and
62 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
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,3 @@ | ||
<div class="row"> | ||
<h1>{{title}}</h1> | ||
<h1>{{$ctrl.title}}</h1> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,16 @@ | ||
angular.module('app').controller('homeController', ['$scope', function($scope){ | ||
$scope.title = 'Awesome, Inc. Internal Ordering System'; | ||
}]); | ||
(function(){ | ||
'use strict'; | ||
|
||
var homeComponent = { | ||
templateUrl: './home/home.html', | ||
bindings: {}, | ||
controller: homeComponentController | ||
}; | ||
|
||
function homeComponentController(){ | ||
var vm = this; | ||
vm.title = 'Awesome, Inc. Internal Ordering System'; | ||
} | ||
|
||
angular.module('app').component('home', homeComponent); | ||
})(); |
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,19 +1,32 @@ | ||
angular.module('app').controller('orderDetailController', ['$scope', 'order', 'productService', 'customerService', | ||
function ($scope, order, productService, customerService) { | ||
$scope.title = 'Order Detail'; | ||
$scope.order = order; | ||
(function(){ | ||
'use strict'; | ||
|
||
activate(); | ||
var orderDetailComponent = { | ||
templateUrl: './orderDetail/orderDetail.html', | ||
bindings: { | ||
order: '<' | ||
}, | ||
controller: orderDetailComponentController | ||
}; | ||
|
||
function activate() { | ||
orderDetailComponentController.$inject = ['productService', 'customerService']; | ||
function orderDetailComponentController(productService, customerService) { | ||
var vm = this; | ||
vm.title = 'Order Detail'; | ||
vm.order = this.order; | ||
|
||
vm.$onInit = function() { | ||
var products = productService.getProducts(); | ||
$scope.customer = customerService.getCustomer($scope.order.customerId); | ||
$scope.order.items.forEach(function (item) { | ||
vm.customer = customerService.getCustomer(vm.order.customerId); | ||
vm.order.items.forEach(function (item) { | ||
var product = _.find(products, function (product) { | ||
return product.id === item.productId; | ||
}) | ||
}); | ||
item.productName = product.name; | ||
item.itemPrice = item.quantity * product.price; | ||
}); | ||
} | ||
}]); | ||
}; | ||
} | ||
|
||
angular.module('app').component('orderDetail', orderDetailComponent); | ||
})(); |
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,17 +1,28 @@ | ||
angular.module('app').controller('ordersController', ['$scope', 'orderService', 'customerService', | ||
function ($scope, orderService, customerService) { | ||
$scope.title = 'Orders'; | ||
(function(){ | ||
'use strict'; | ||
|
||
activate(); | ||
var ordersComponent = { | ||
templateUrl: './orders/orders.html', | ||
bindings: {}, | ||
controller: ordersComponentController | ||
}; | ||
|
||
function activate() { | ||
$scope.customers = customerService.getCustomers(); | ||
$scope.orders = orderService.getOrders(); | ||
$scope.orders.forEach(function (order) { | ||
var customer = _.find($scope.customers, function (customer) { | ||
ordersComponentController.$inject = ['orderService', 'customerService']; | ||
function ordersComponentController(orderService, customerService) { | ||
var vm = this; | ||
vm.title = 'Orders'; | ||
|
||
vm.$onInit = function() { | ||
vm.customers = customerService.getCustomers(); | ||
vm.orders = orderService.getOrders(); | ||
vm.orders.forEach(function (order) { | ||
var customer = _.find(vm.customers, function (customer) { | ||
return order.customerId === customer.id; | ||
}) | ||
}); | ||
order.customerName = customer.fullName; | ||
}); | ||
} | ||
}]); | ||
}; | ||
} | ||
|
||
angular.module('app').component('orders', ordersComponent); | ||
})(); |
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,19 +1,19 @@ | ||
<div class="row"> | ||
<h1>{{title}}: {{product.name}}</h1> | ||
<h1>{{$ctrl.title}}: {{$ctrl.product.name}}</h1> | ||
</div> | ||
<div class="row"> | ||
<div class="col-md-3"> | ||
<b>Color:</b> | ||
</div> | ||
<div class="col-md-4 end"> | ||
{{product.color}} | ||
{{$ctrl.product.color}} | ||
</div> | ||
</div> | ||
<div class="row"> | ||
<div class="col-md-3"> | ||
<b>Price:</b> | ||
</div> | ||
<div class="col-md-4 end"> | ||
{{product.price | currency}} | ||
{{$ctrl.product.price | currency}} | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,19 @@ | ||
angular.module('app').controller('productDetailController', ['$scope', 'product', function($scope, product){ | ||
$scope.title = 'Product Detail'; | ||
$scope.product = product; | ||
}]); | ||
(function(){ | ||
'use strict'; | ||
|
||
var productDetailComponent = { | ||
templateUrl: './productDetail/productDetail.html', | ||
bindings: { | ||
product: '<' | ||
}, | ||
controller: productDetailComponentController | ||
}; | ||
|
||
function productDetailComponentController(){ | ||
var vm = this; | ||
vm.title = 'Product Detail'; | ||
vm.product = this.product; | ||
} | ||
|
||
angular.module('app').component('productDetail', productDetailComponent); | ||
})(); |
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,21 @@ | ||
angular.module('app').controller('productsController', ['$scope', 'productService', function($scope, productService){ | ||
$scope.title = 'Products'; | ||
(function(){ | ||
'use strict'; | ||
|
||
activate(); | ||
var productsComponent = { | ||
templateUrl: './products/products.html', | ||
bindings: {}, | ||
controller: productsComponentController | ||
}; | ||
|
||
function activate(){ | ||
$scope.products = productService.getProducts(); | ||
productsComponentController.$inject = ['productService', ]; | ||
function productsComponentController(productService){ | ||
var vm = this; | ||
vm.title = 'Products'; | ||
|
||
vm.$onInit = function(){ | ||
vm.products = productService.getProducts(); | ||
}; | ||
} | ||
}]); | ||
|
||
angular.module('app').component('products', productsComponent); | ||
})(); |