Last active
August 29, 2015 14:13
-
-
Save simonmorley/675b9e5c7e7583d92ebf to your computer and use it in GitHub Desktop.
Medium, creating a splash, welcome directive
This file contains hidden or 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
| app.directive('welcome', ['$routeParams', '$location', '$window', 'Login', '$timeout', function($routeParams, $location, $window, Login, $timeout) { | |
| var link = function(scope,element,attrs) { | |
| scope.loading = true; | |
| var request_uri = $location.host(); | |
| var apMac = $routeParams.mac || $routeParams.sip; | |
| Login.welcome({request_uri: request_uri, mac: apMac}).$promise.then(function(results) { | |
| scope.loading = undefined; | |
| scope.welcome = results.welcome; | |
| if (results.timeout > 0) { | |
| var timeout = results.timeout * 1000; | |
| var redirectTo = results.success_url || 'https://google.com'; | |
| $timeout(function() { | |
| $window.location.href = redirectTo; | |
| },timeout); | |
| } | |
| }); | |
| }; | |
| return { | |
| link: link, | |
| replace: true, | |
| scope: false, | |
| template: '<div><p ng-bind-html="welcome"></p></div>' | |
| }; | |
| }]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment