Skip to content

Instantly share code, notes, and snippets.

@dsummersl
Created July 18, 2017 19:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dsummersl/26b61395af462a1320c370107bf0877b to your computer and use it in GitHub Desktop.
Save dsummersl/26b61395af462a1320c370107bf0877b to your computer and use it in GitHub Desktop.
import * as angular from 'angular';
import {html} from './ProductDetails.html';
import {ClipartProductService} from '../../../../../common/ts/apps/svgcustom/services/ClipartProductService';
import {Color} from '../../../../../common/ts/apps/svgcustom/models/Color';
class ProductDetailsController {
static $inject = [
'productSlug',
'ClipartProductService'
];
constructor(private productSlug: string, public cpService: ClipartProductService) {
cpService.fetchClipartProduct(this.productSlug);
}
get description() {
return this.cpService.product.description;
}
get id() {
return this.cpService.product.id;
}
get name() {
return this.cpService.product.name;
}
get price() {
return this.cpService.price.price;
}
get quantity() {
return this.cpService.price.quantity;
}
get unitPrice() {
return this.cpService.price.unitPrice;
}
}
export default function ProductDetails() {
return {
controller: ProductDetailsController,
controllerAs: '$ctrlPD',
template: html,
name: 'svgcustom:product-details',
resolve: {
productSlug: ['$route', ($route) => {
// TODO move fetching here, so that we can return a promise with
// failure and rerouting.
// cpService.bind('setupComplete', () => {
// const configuredProduct = cpService.configuredProduct;
// console.log(cp);
// });
return $route.current.params.productSlug;
}]
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment