0

As per Microsoft's instructions, I am attempting to embed a yammer feed using the following code:

<div id="embedded-feed" style="height:800px;width:400px;"></div>
<script type="text/javascript" src="https://s0.assets-yammer.com/assets/platform_embed.js"></script>
<script type="text/javascript">
yam.connect.embedFeed({
    container: "#embedded-feed",
    network: "companyname.com",
    feedType: "group",
    feedId: "3777284"
});
</script>

When I put that exact code in my Home.aspx page, the Yammer feed appears as intended. The only problem is my page has tabs that incorporate an ng-switch statement to display the correct content div for the selected tab, at which point a directive injects the HTML template into that div. No problem, I thought, I can just put the above code into my template file. For some reason, when I put that exact same code into my template file, the Yammer feed does not appear. The div where the yammer feed should be does, but the feed itself is no where to be found. Here's what declaring my directive looks like:

angular.module('mainApp').directive('home', function () {
    return {
        restrict: 'A',
        templateUrl: 'templates/home.html'
    };
});

For all intents and purposes, assume my home.html template contains only the code in the first code block. The console doesn't display any error messages, by the way. Why does my Yammer feed embedding work when it's directly inserted into my Home.aspx, but not when I use a directive to insert it? Thanks in advance.

  • Might it be better to ask this in an Angular forum as there is nothing SharePoint in it? – Danny '365CSI' Engelman Mar 23 '17 at 9:15
  • @Danny'365CSI'Engelman Yeah that's true, it's actually hosted on SharePoint but I guess that's probably irrelevant. Thanks! – YungGun Mar 23 '17 at 12:51
  • This is a wild stab. Doesn't that Yammer thingie inject an IFRAME and could Angular (haven't used it, since 2.0 sucks) be blocking something. – Danny '365CSI' Engelman Mar 23 '17 at 13:22
  • @Danny'365CSI'Engelman I have no idea, I got it working though I had to move the <script> to the main .aspx and then put the JS code into the pages controller, with the <div> where the feed would be injected in the template file. – YungGun Mar 23 '17 at 13:43
0

Fixed it by moving the <script> tag linking the yammer feed embed code to the main .aspx page, moved the embed JS code to that pages controllers, and kept the <div> where the feed would be injected in the home.html template file. Works fine now, although I have no better understanding of why.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.