Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
/**
* 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