Skip to content

Instantly share code, notes, and snippets.

@camwest
Created March 7, 2014 14:17
Show Gist options
  • Save camwest/9412266 to your computer and use it in GitHub Desktop.
Save camwest/9412266 to your computer and use it in GitHub Desktop.
// define main angular module
var app = angular.module('app-module', []);
// inject $provide into the application config
app.config(['$provide', function($provide) {
// provide the LOGIN_DATA as a constant to angular
$provide.constant('LOGIN_DATA', window.LOGIN_DATA)
}]);
app.controller('MyCtrl', function(LOGIN_DATA) {
// LOGIN DATA is now available inside controllers
console.log(LOGIN_DATA);
});
// wait until dom loads
$(function() {
// get use login details
$.get(‘/user_login_details.json’, function(data) {
// store data in a global
window.LOGIN_DATA = data;
// bootstrap angular
angular.bootstrap( $(‘#root-app-element’), [‘app-module’] );
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment