ottz0 ottz0 - 2 years ago 76
AngularJS Question

Returning promise of then not a function

I am using Ionic/AngularJs to set default colors in my app.

I have setup a service for this that returns an object.

I have also setup the promise in my controller but i'm getting "ThemeColors.setColor of then is not a function"


.controller('ColorCtrl', function($scope, $location, ThemeColors) {

$scope.mmAsideColor = ThemeColors.setDefaultColors.asideColor;
$scope.setColor = function(appColor){
$ = data;


.factory('ThemeColors', function() {

return {
"backgroundColor": "mm-royal",
"asideColor": "mm-royal",
"buttonColor": "button-royal"
setColor: function(appColor){
return {
"asideColor": "The Color is" + appColor
//"asideColor": "mm-"+appColor,

Answer Source

Your factory needs to return a promise, but you are returning just the result, so you don't need then,

$scope.setColor = function(appColor){     
        $ = ThemeColors.setColor(appColor);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download