Created
March 21, 2016 20:06
-
-
Save washingtonsoares/2131c3f3a2f1da21e516 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
angular | |
.module('ionicApp.state.CampaingCategoryController', []) | |
.controller('CampaingCategoryController', ['$scope','CampaingCategoryFactory', function ($scope, CampaingCategoryFactory) { | |
console.log('CampaingCategoriesController loaded'); | |
// CampaingCategoryFactory.hello(); | |
// CampaingCategoryFactory.categories(); | |
// CampaingCategoryFactory.category(); | |
$scope.categories = CampaingCategoryFactory.categories().then(function(data){ | |
$scope.dados = data; | |
},function(){ | |
//erro ao buscar os dados | |
}; | |
}]); |
This file contains hidden or 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
angular | |
.module('ionicApp.state.CampaingCategoryFactory', []) | |
.factory('CampaingCategoryFactory', function($http, $q){ | |
var sayHello = function() { | |
console.log('hello from factory'); | |
}; | |
var getCampaingCategories = function() { | |
var deferral = $q.defer(); | |
$http({ | |
method: 'GET', | |
url: 'http://0.0.0.0:3000/campaing_categories' | |
}).success(function(data){ | |
deferral.resolve(data); | |
}).error(function(){ | |
deferral.reject(); | |
}); | |
return deferral.promise; | |
}; | |
var getCategory = function() { | |
}; | |
return { | |
categories: getCampaingCategories, | |
category: getCategory, | |
hello: sayHello | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment