1

I've a strange behavior with this code

.controller('ContestantCreateCtrl',function($scope,CONFIG) {
       $scope.shareurl = 'https:'+CONFIG.site.absoluteUrl+'/';
})
.directive('btFbParse', function () {
        return {
            restrict:'A',
            link:function (scope, element, attrs) {
               console.log(scope.shareurl);//it works
               if(scope.facebookIsReady){
                    FB.XFBML.parse();
               }
            }
        };
 })

if in the view I set up

<div class="fb-like" data-href="https://my-dev.me/public/" data-width="120"  data-colorscheme="light" data-layout="standard" data-action="like" data-show-faces="true" data-send="false"></div>
<div bt-fb-parse></div>

it works

but if in the view I set up

<div class="fb-like" data-href="{{shareurl}}" data-width="120"  data-colorscheme="light" data-layout="standard" data-action="like" data-show-faces="true" data-send="false"></div>
<div bt-fb-parse></div>

I get form facebook api "/plugins/error/api?code=100&message=The+href+URL+must+be+absolute&hash=AQDVWDuDsG3_aVQh

I tried also with

scope.$apply() 

in the directive the fb like works but angular show me a Error: $digest already in progress

I don't know which way to turn ....

Update

with

_.defer(function(){
                        scope.$apply();
                        FB.XFBML.parse();
                    });

it works :)

thanks to https://stackoverflow.com/a/17958847/356380

Community
  • 1
  • 1
Whisher
  • 31,320
  • 32
  • 120
  • 201

0 Answers0