i can successfully get data from the /api/session.json call and log it to my console.
how do i send the output of this api call to my index.html file and replace "Username"?
thanks!
here is my app.js file for my angular application:
'use strict';
var staticApp = angular.module('staticApp', [])
.config(['$routeProvider', function($routeProvider) {
$routeProvider
.when('/', {
templateUrl: 'views/main.html',
controller: 'MainCtrl'
})
.otherwise({
redirectTo: '/'
});
}])
.run( function($http) {
$http.defaults.useXDomain = true;
// API CALL
$http({method: 'GET', url: '/api/session.json'}).
success(function(data, status, headers, config) {
// THIS WORKS!!
// MY CONSOLE SHOWS THIS:
// Object {user: "devuser"}
console.log(data);
}).
error(function(data, status, headers, config) {
console.log(status);
});
});
and here is my index.html fiile:
<!DOCTYPE html>
<head>
<!-- meta and css stuff -->
</head>
<body ng-app="staticApp">
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container-fluid">
<button type="button"
class="btn btn-navbar"
data-toggle="collapse" data-target=".nav-collapse">
</button>
<a class="brand" href="/">MyApp</a>
<div class="nav-collapse collapse">
<p class="navbar-text pull-right">
<!-- I WANT Username TO BE THE VALUE RETURNED FROM THE API CALL -->
Logged in as <a href="#" class="navbar-link">Username</a>
</p>
</div><!--/.nav-collapse -->
</div>
</div>
</div>
<div class="container" ng-view></div>
<script src="scripts/vendor/angular.js"></script>
<script src="scripts/app.js"></script>
<script src="scripts/controllers/main.js"></script>
</body>
</html>
{{username}}. (Sorry no example code; typing on a tablet.)