Skip to content

Instantly share code, notes, and snippets.

@wesleycho
Last active August 29, 2015 14:00
Show Gist options
  • Save wesleycho/11089996 to your computer and use it in GitHub Desktop.
Save wesleycho/11089996 to your computer and use it in GitHub Desktop.
'use strict';
printio.controller('ProductDetailsCtrl', function($scope, $routeParams, $filter, Printio) {
Printio.getProducts()
.then(fetchProduct)
.then(getShipEstimate)
.then(openProduct)
function fetchProduct(data) {
$scope.product = data.Products.filter(function(p) {
return p.Name.replace(/\s/g, '-').toLowerCase() === $routeParams.productName;
})[0];
$scope.images = $filter('productList')($scope.product);
$scope.mainImage = {};
return $scope.product.id;
}
function getShipEstimate(id)
return Printio.getShipEstimate(id, 'us', 'usd')
}
function openProduct(data) {
$scope.shipEstimate = data;
$scope.openPIO = function() {
PIO.open({
items:[{productId: $scope.product.Id}],
goTo:'tpl-newcustomize'
});
};
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment