Created
January 20, 2015 12:16
-
-
Save simonmorley/ddaab804c93b54af7d0d to your computer and use it in GitHub Desktop.
basic controller for ct logins
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
'use strict'; | |
var app = angular.module('ctLoginsApp.logins.controller', []); | |
app.controller('LoginsController', ['$rootScope', '$scope', '$routeParams', 'Login', | |
function($rootScope, $scope, $routeParams, Login) { | |
$scope.loading = true; | |
var init = function(request_uri, apMac) { | |
Login.initialise({request_uri: request_uri, mac: apMac}).$promise.then(function(results) { | |
buildPage(results); | |
}, function(err) { | |
displayError(err); | |
}); | |
var buildPage = function(data) { | |
addCopy(data); | |
}; | |
var addCopy = function(data) { | |
$scope.data = data.splash; | |
$scope.loading = undefined; | |
}; | |
var displayError = function(err) { | |
$scope.errors = true; | |
console.log(err) | |
}; | |
}; | |
$scope.init = function() { | |
var request_uri = $location.host(); | |
var mac = $routeParams.mac || $routeParams.sip; | |
init(request_uri, mac); | |
}; | |
$scope.$on('$routeChangeSuccess', function (event, current, previous) { | |
$scope.init(); | |
}); | |
} | |
]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment