angular-block-ui icon indicating copy to clipboard operation
angular-block-ui copied to clipboard

Change message from blockUIConfig after app.config()

Open ruisilva450 opened this issue 8 years ago • 1 comments
trafficstars

Hi, I wanted to load a default message that changes after translation data arrive. My workflow is as follows: 1)

app.config(['blockUIConfig', function (blockUIConfig) {
        blockUIConfig.message ='Wait for it...';
}]);
app.config(['$translateProvider', function ($translateProvider) {
        ...
        $translateProvider.useLoader('customLoader');
}]);

app.factory('customLoader', ['$http', '$q', '$rootScope', function ($http, $q, $rootScope) {
        return function (options) {
            var deferred = $q.defer();
            $http.get(url).success(function (results) {
                deferred.resolve(results);
                $rootScope.loadedResources = true;
                ...
            }
        }
}]);
// Somehow do something like this on app.run(blockUIConfig)
blockUIConfig.message ="{{'loading_text' | translate}}";

Someone can drive me through it?

ruisilva450 avatar Dec 20 '16 12:12 ruisilva450

Your example from "3." should actually work, I think your issue is getting the translated string.

Angular binding expressions does not work in JS, you need to use $compile service or (better for your case) $filter service, something like this:

// Somehow do something like this on app.run(blockUIConfig) blockUIConfig.message = $filter('translate')('loading_text');

octavian-mirica avatar Jan 04 '17 16:01 octavian-mirica