app.directive('login', function() {
return {
restrict: "A",
scope: true,
controller: function($scope, authentication, $state, jwt, $cookies) {
$scope.user = {};
$scope.login = function() {
authentication.login($scope.user)
.success(function(response, status, headers) {
var headersObject = headers();
jwt.set(headersObject.token);
$scope.errors = null;
$scope.hasErrors = false;
$state.go('sms');
(see full text)