Hi friends
I have to do like this to getting user log in information before bootstrap 
angular app. Do we have a better way ?
I don't want to use $http.get('/api/settings/account.json') to call api, I 
want to use AuthService.getUserInfo() but I can't get this service if i 
don't bootstrap angular app first.
My question is, in angular do we have an initialize resolve callback 
function like application_start ?
userInfo = null

angular.module 'gnp-app', modules
  .config ['$routeProvider',  ($routeProvider) ->
    $routeProvider
      .otherwise
        redirectTo: '/'
  ]
  .config ['$httpProvider', ($httpProvider) ->
    $httpProvider.defaults.headers.common['X-CSRF-Token'] =
      $('meta[name=csrf-token]').attr('content')
  ]
  .config ['$locationProvider', ($locationProvider) ->
    $locationProvider.html5Mode(true)
  ]
  .run ['AuthService', (AuthService) ->
    AuthService.setUserInfo(userInfo)
  ]

$http = angular.injector(["ng"]).get("$http")
$http.get('/api/settings/account.json').then (response) ->
  userInfo = response.data
.finally ->
  angular.element(document).ready ->
    angular.bootstrap(document, ["gnp-app"])


-- 
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.

Reply via email to