nourdine
nourdine

Reputation: 7597

Bootstrap data in angular js

I am working on a angular one page application and I was wondering how to feed the app with data that are dynamically generated in the server side when the page first load.

Something like this:

var bootstrapValues = {
   totalNumberOfPosts: 345,
   postsPerPage: 10,
   // etc. etc.
}

What is a good way to enter this configuration hash into the app?

Thanks

Upvotes: 1

Views: 42

Answers (1)

Kalhan.Toress
Kalhan.Toress

Reputation: 21901

do it in run

app.run(function($rootScope, $http) {
    $http.get(configurationUrl).success(function(data) {
        $rootScope.bootstrapValues = data;
    }).error(function() {
    });
})

Upvotes: 3

Related Questions