kadirahq / meteor-dochead

Isomorphic way to manipulate document.head for Meteor apps
MIT License
131 stars 17 forks source link

Duplicated Meta Tags #26

Closed dyaa closed 8 years ago

dyaa commented 8 years ago

Hello,

I'm using Dochead with Urigo/angular-meteor and i have an issue with DocHead.addMeta it append the meta Tags instead of replace it.

How can avoid that append!

fixes dyaa/deeMeteor#6

desctop screenshot

arunoda commented 8 years ago

Call this for every route change: https://github.com/kadirahq/meteor-dochead/blob/master/lib/both.js#L79

arunoda commented 8 years ago

Some more information: https://github.com/kadirahq/meteor-dochead#docheadremovedocheadaddedtags

dyaa commented 8 years ago

Thank you :)

dyaa commented 8 years ago

Just adding this for other folks who are looking for the same issue.

angular.module("app").run(function ($rootScope, $state) {
    $rootScope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams){
        const elements = document.querySelectorAll('[dochead="1"]');
        // We use for-of here to loop only over iterable objects
        for (let element of elements) {
            element.parentNode.removeChild(element);
        }
    });
});