Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- this.saveProductCategory = function() {
- var productCategory = {
- name: $scope.productCategory
- };
- var promise = ProductCategory.saveProductCategory(productCategory)
- .then(function(data) {
- $scope.vendorProductData.product_category_id = data.id;
- })
- .catch(function(data) {
- $scope.message = data;
- });
- return promise;
- };
- this.saveVendorProduct = function() {
- var functionsToExecute = [];
- if(!$scope.vendorProductData.product_name_id) {
- functionsToExecute.push(this.saveProductName());
- }
- if(!$scope.vendorProductData.product_type_id) {
- functionsToExecute.push(this.saveProductType());
- }
- if(!$scope.vendorProductData.product_category_id) {
- functionsToExecute.push(this.saveProductCategory());
- }
- $q.all(functionsToExecute)
- .then(
- VendorProduct.saveVendorProduct($scope.vendorProductData)
- .then(function(data) {
- $state.go('products');
- })
- .catch(function(data) {
- $scope.message = data;
- })
- );
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement