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
.controller('ColorCtrl', function($scope, $location, ThemeColors) {
$scope.mmAsideColor = ThemeColors.setDefaultColors.asideColor;
$scope.setColor = function(appColor){
ThemeColors.setColor(appColor)
.then(function(data){
$scope.data = data;
console.log(data);
});
}
})
.factory('ThemeColors', function() {
return {
setDefaultColors:{
"backgroundColor": "mm-royal",
"asideColor": "mm-royal",
"buttonColor": "button-royal"
},
setColor: function(appColor){
return {
"asideColor": "The Color is" + appColor
}
//"asideColor": "mm-"+appColor,
}
}
});
Your factory needs to return a promise, but you are returning just the result, so you don't need then,
$scope.setColor = function(appColor){
$scope.data = ThemeColors.setColor(appColor);
}