0

I want to change the iframe source on runtime

<div class="pp lsv-video pp-player" id="rs" ng-controller="ctrl2">
        <input type="text" style="width:0px;height:0px;display:none;"  />
        <iframe src="" class="lsv" marginheight="0" marginwidth="0" frameborder="0"></iframe>
    </div>

when user clicks on any of the

  • (mentioned below), teh data mentioned b.VideoSrc should be transferred to the different controller Ctrl2 and iframe source has to be changed.
    <ul ng-controller="ctrl1">
                            <li ng-repeat="b in KeynoteSessions | filter:isBD">
                                <a href='#rs' class="fancybox" name='{{b.VideoSrc}}'>
                                    <img src='{{b.ImageSrc}}' width='{{b.ImageWidth}}' height='{{b.ImageHeight}}' alt='{{b.ImageAlt}}' /><br />
                                    {{b.Text}}
                                </a>
                            </li>
                        </ul>
    

    please help me to achieve this, thanks!

  • AChauhan
    • 207
    • 3
    • 15

    2 Answers2

    1

    there are many ways 1.You can create services and use common services to share data. 2.you can use rootscope variable. 3.angularjs $emit, $broadcast methods you can use like

    myApp.factory('Data', function () {
        return { FirstName: '' };
    });
    
    myApp.controller('FirstCtrl', function ($scope, Data) {
        $scope.Data = Data;
    });
    
    myApp.controller('SecondCtrl', function ($scope, Data) {
        $scope.Data = Data;
    });
    

    http://jsfiddle.net/HEdJF/

    check this one:Share data between AngularJS controllers

    Community
    • 1
    • 1
    Arun
    • 1,177
    • 9
    • 15
    0

    Usually I'm putting related content in the same controller (Youtube frame and "remote" together for exemple) but sometime I can't, so I pass the data through a Javascript Variable (Dont forget that your var need to be defined outside your controller )

    Kable
    • 31
    • 3