Skip to content

Instantly share code, notes, and snippets.

@klaascuvelier
Created July 17, 2013 07:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save klaascuvelier/6018424 to your computer and use it in GitHub Desktop.
Save klaascuvelier/6018424 to your computer and use it in GitHub Desktop.
/**
* Inject urls into the url service
*/
Module.directive('url', ['$url', function injectUrlData($url) {
return {
restrict : 'A',
compile: function() {
return {
pre: function(scope, element, attrs) {
var lines = element[0].innerHTML.split(';');
angular.forEach(lines, function (line, index) {
var data = line.split('='),
key, val;
if (data.length === 2) {
key = $.trim(data[0]);
val = $.trim(data[1]);
$url.set(key, val);
}
});
}
};
}
};
}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment