Skip to content

Instantly share code, notes, and snippets.

@in-async
Created March 10, 2015 07:41
Show Gist options
  • Save in-async/40ba9a9646797829ade1 to your computer and use it in GitHub Desktop.
Save in-async/40ba9a9646797829ade1 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>JS Bin</title>
<style>
body {
margin: 0;
font-size: 30px;
line-height: 1.25;
}
#content {
padding: .5em;
background-color: #eee;
height: 600px;
}
</style>
</head>
<body ng-app='myApp'>
<div id="content" ng-controller='fooCtrl'>
{{foo}} at {{location}}
</div>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.2/angular.min.js"></script>
<script>
angular.module('myLib', [])
.factory('absoluteUrl', ['$location', function($loc) {
return function() {
return $loc.absUrl();
};
}]);
angular.module('myApp', ['myLib'])
.controller('fooCtrl', ['$scope', 'absoluteUrl', function($scope, url) {
$scope.foo = 'foo by app';
$scope.location = url();
}]);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment