Created
March 7, 2014 14:17
-
-
Save camwest/9412266 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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