Thanks, I appreciate it, will try it. On Tuesday, April 15, 2014 7:24:38 AM UTC+3, Gordon Bockus wrote: > > Hum...I had to look around quite a bit to find a solution that would work > for this. I think you need to first create a module to hold you > configuration data. Check out his article for an example of what that > would look like: > > http://newtriks.com/2013/11/29/environment-specific-configuration-in-angularjs-using-grunt/ > > It uses grunt, but you could start by just hard coding your config in a > module. There are other less elegant solutions using globals. Check out > this thread: https://groups.google.com/forum/#!topic/angular/B1pRpV-_ig4 > > > Then the simplest solution I could come up with for having your decorator > work as expected would be to move it to a .run for you application > injecting the configuration module you created. > > So the heart of the answer is don't load the configuration asynchronously. > Instead load it directly before you app is bootstrapped so you have the > data when you need it for use in a decorator. > > Gordon > > > > On Sunday, April 13, 2014 2:41:44 AM UTC-5, Daniel Reznick wrote: >> >> Hi, >> >> I'm using the decorator to decorate the $log and the $exceptionHandler >> services and I want to set the logger level and some other stuff in the log >> decorator base on configuration that I retrieve from the server, >> >> The configuration from the server is being retrieved by using the resolve >> of $routeProvider >> >> templateUrl: 'pages/home.html', >> controller: 'HomeCtrl', >> resolve: { >> myConfig: function (appConfig) { >> return appConfig.retreiveConfig(); >> } >> } >> >> >> >> >> I tried to $rootScope.$broadcast an event when I retrieve the config from >> the server and use $injector.get('$rootScope'); inside the log decorator , >> like this >> >> var $rootScope = $injector.get('$rootScope'); >> $rootScope.$on('app-config-loaded', function (event, one, two) { >> console.log('heard something...'); >> }); >> >> But I'm getting Uncaught Error: [$injector:cdep] Circular dependency >> found: $log <- $exceptionHandler <- $rootScope >> >> Original question: >> http://stackoverflow.com/questions/22980830/how-to-access-server-side-configuration-in-log-decorator >> >> How can I use the configuration loaded in the routing resolve inside my >> $log decorator ? >> >
-- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.
