Skip to content

Latest commit

 

History

History
64 lines (40 loc) · 1.71 KB

File metadata and controls

64 lines (40 loc) · 1.71 KB

angular-hal

Build Status

Help wanted!

If you feel like helping out, plese contact me!

use it in your project!

Easy installation using bower

bower install angular-hal

then, reference the js files in your html page

<script src="proxy.php?url=https%3A%2F%2Fgithub.com.%2Fbower_components%2Frfc6570%2Frfc6570.js"></script>
<script src="proxy.php?url=https%3A%2F%2Fgithub.com.%2Fbower_components%2Fangular-hal%2Fangular-hal.js"></script>

You may use it like this:

angular
.module('app', ['angular-hal'])
.run([
	'$rootScope'
	, '$window'
	, 'halClient'
	, function(
		$rootScope
		, $window
		, halClient
	) {
		var token = $window.sessionStorage.getItem('token');

		$rootScope.apiRoot = halClient.$get('https://api.example.com/', {
			authorization: token && 'Bearer ' + token + ''
		});

		$rootScope.$watch('apiRoot', function(apiRoot){
			$rootScope.authenticatedUser = apiRoot.$get('http://example.com/authenticated-user');
		});

	}
])//run

stay tuned for more!

check this out!

compatibility

If you wish to use this service in old (ie) browsers, you may need to use the following polyfills: