1

Hi I'm trying to build something with angular where you can submit the url of a tweet and it will embed the tweet. I thought I could just stick the handlebars inside of embedly's twitter widget but it doesn't work. It's something maybe about the order in which the events are firing.

This is the code

<section data-ng-controller="ArticlesController">

{{article.title}}<p>

<a class="embedly-card" href="{{article.title}}">hi</a><p>

<a class="embedly-card" href="https://twitter.com/jashkenas/status/563803426107449347">bye</a>

<a class="embedly-card" ng-href="{{article.title}}">why</a>

</section>

And this is the result

As you can see I tried it a few different ways and it works when it just has the url pasted in there but not with the angular data. Although when you click on the hi and why links they do take you to the right place.

This is inspecting the page

The one that worked created this whole iframe but the others are just plain links.

Should also say theres an embedly script which I put in the header

<script async src="//cdn.embedly.com/widgets/platform.js" charset="UTF-8"></script>

Any help is much appreciated. I don't really know angular, I just wanted to play around and learn a bit about it. I guess maybe I am now. Thanks.

4
  • it seems twitter widget rendering is before Angular DOM rendering, maybe that's why twitter widget can not understand attribute href Commented Feb 11, 2015 at 4:49
  • yeah I was thinking the same thing, I wonder if there's any way to delay the widget script from running. Commented Feb 11, 2015 at 5:05
  • you can refer to these projects 1 2 for how to handle rendering issues, hope it work. Commented Feb 11, 2015 at 5:27
  • I have posted my answer. You may want to mark it as correct then others who have similar issues can have an idea how to troubleshoot :) Commented Feb 11, 2015 at 5:32

2 Answers 2

1

The problem you met is that embedly renders the element before Angular renders the DOM element, which means embedly may don't know what the href actually is and it stops rendering and left nothing.

You can refer to these projects 1 2 for how to handle rendering sequence.

Sign up to request clarification or add additional context in comments.

2 Comments

not having any luck getting that running there must be an easier way
like cant i delay the embedly script from running until after the DOM loads
0

so I ended up just delaying the embedly script loading with this js

setTimeout(function() {
    var headID = document.getElementsByTagName("head")[0];         
    var newScript = document.createElement('script');
    newScript.type = 'text/javascript';
    newScript.src = 'http://www.somedomain.com/somescript.js';
    headID.appendChild(newScript);
}, 5000);

i found here https://stackoverflow.com/a/9611751/927591

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.