how to use iframe in angularJS -


i want change scrolltop of iframe after load. idea.

in template

<iframe .. onload="{{loaded()}}" ..></iframe> 

in controller

$scope.loaded = function() {     //chage scroll of iframe } 

but think not angular style("do not kind of dom manipulation")

what best practice this?

here mycode. cross-domain not working..

directive('myiframe', function(){     var linkfn = function(scope, element, attrs) {         element.find('iframe').bind('load', function (event) {           event.target.contentwindow.scrollto(0,400);         });     };     return {       restrict: 'ea',       scope: {         src:'@src',         height: '@height',         width: '@width',         scrolling: '@scrolling'       },       template: '<iframe class="frame" height="{{height}}" width="{{width}}" frameborder="0" border="0" marginwidth="0" marginheight="0" scrolling="{{scrolling}}" src="{{src}}"></iframe>',       link : linkfn     };   }); 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -