header controller gets current user and displays it

angular
Matt Huntington 10 years ago
parent 8c9723726d
commit 0ed4ee13e7

@ -1,5 +1,9 @@
var app = angular.module('SinsApp', []);
app.controller('HeaderController', function(){
this.foo = 'bar'
});
app.controller('HeaderController', ['$http', function($http){
var controller = this;
$http.get('/session').success(function(data){
controller.current_user = data.current_user;
console.log(controller.current_user);
})
}]);

@ -1,6 +1,6 @@
<header ng-controller="HeaderController as header">
<h1>Greetings Reprobates!</h1>
{{header.foo}}
<h1>Greetings {{header.current_user.email}}, you are a glorious reprobate!</h1>
</header>
<main>
main!

Loading…
Cancel
Save