I have developed a service in my application to retrieve configuration settings from the database. This service is used to display various configurations across different parts of the app. However, I am encountering an issue where the variables do not update on the configs page until I manually refresh the page.
THE SERVICE:
app.factory('dataShare', function($rootScope, $log, $q, $http, Data) {
var configs= {};
configs.getconfigs=function(){
var deferred = $q.defer();
Data.get('config').then(function(data){
deferred.resolve(data.data);
});
return deferred.promise;
}
return configs;
});
THE CONTROLLER:
app.controller('authCtrl', function ($scope, $rootScope, $routeParams, $log, $location, $http, dataShare) {
dataShare.getconfigs().then(function(data){
$scope.configs = data;
});
});
HTML SNIPPET:
<div class="col-md-2"><span ng-if="configs[0].button_name"><a class="btn btn-sm btn-info navbar-btn" ng-href="{{configs[0].button_url}}">{{configs[0].button_name}}</a></span></div>
Any assistance or advice on this issue would be greatly appreciated.