If your framework gives back a token, you just have to add it to the headers for all subsequent requests.
Making this permanent requires additional code (ex: writing it in localStorage)
I don't know the Header that your framework wants :) but i can assume your login controller might look like this:
angular.module('coolModule', [])
.controller('CoolController', function ($scope, $http) {
$scope.loginButton = function () {
// assuming username and password are in the scope
$http.post('/api/login', { $scope.username, $scope.password })
.success(function (data, status, headers, config) {
$http.defaults.headers.common['X-My-Token'] = data.token;
});
}
})
Subsequent requests will have a X-My-Token header, that usually works for identification
EDIT:
Yes, setting a cookie (in javascript or from a server response) will make it get sent at every request (like all the cookies in this internet world)
If you are developing also the backend would be much more elegant make the backend send a cookie to the client, and not writing it manually as you commented ^_^
A cookie has some pros: like an expiration date, and some cons: reading it from javascript is not really elegant (usually requires a wrapper lib, angular-cookie, for browser compatibility).
In both cases when a cookie expires or the token is invalid (so you will receive a 40x response) you will have to handle the failure using some angular.js code