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
Post a Comment