Skip to content

Instantly share code, notes, and snippets.

View theninthnode's full-sized avatar

Billy Jones theninthnode

View GitHub Profile
@theninthnode
theninthnode / Angular canonical tags
Created August 9, 2013 08:36
Little snippet to set canonical links in AngularJS. Note. this will only work with crawlers if you implement some sort of interceptor and return fully rendered html/js to the crawler i.e. using PhantomJS
$rootScope.$watch('canonical', function(newVal){
if(newVal != '') {
var link = angular.element('<link>');
link.attr('rel', 'canonical');
link.attr('href', newVal);
angular.element('head').append(link);
}
})