og meta tags, social buttons and angularjs

前端 未结 2 402
予麋鹿
予麋鹿 2020-12-01 06:54

I\'m creating a website using multiple views. The tag and the tags of the page get changed through a a $rootScope variable. so I have something like



        
2条回答
  •  感情败类
    2020-12-01 07:25

    There's also a possibility that you can re-render Facebook widgets. Use their parse method:

    FB.XFBML.parse();
    

    after your angular stuff has completed. It's not working for my share button (yet!!), but I tested it on likes, and it's cool. Basically it re-scans the DOM and renders the Facebook widgets. You can also pass it a single element, something like this directive:

    'use strict';    
    angular.module('ngApp')
    .directive("fbLike", function($rootScope) {
        return function (scope, iElement, iAttrs) {
            if (FB && scope.$last) {
                FB.XFBML.parse(iElement[0]);
            }
        };
    });
    

    This snippet would rescan the DOM for html5 facebook fb-like widgets when creating the last element in angular repeater.

提交回复
热议问题