Skip to content

Instantly share code, notes, and snippets.

@simonmorley
Created January 20, 2015 12:16
Show Gist options
  • Save simonmorley/ddaab804c93b54af7d0d to your computer and use it in GitHub Desktop.
Save simonmorley/ddaab804c93b54af7d0d to your computer and use it in GitHub Desktop.
basic controller for ct logins
'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