带有 iframe 的 AngularJs [英] AngularJs with iframe

查看:24
本文介绍了带有 iframe 的 AngularJs的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么 这个 jsfiddle 不起作用?我无法获得 videoId 的值.如果我从模块中删除 ngRoute 那么它工作正常.

Why this jsfiddle is not working? I am not able to get value of videoId. If I remove ngRoute from module then it is working fine.

推荐答案

你需要像这样使用ng-src:

<div ng-controller="AppController">
    <h1>{{videoID}}</h1>
    <iframe class="youtube-player" type="text/html" width="auto"
    height="auto" ng-src="{{videoID}}"
    allowfullscreen="" frameborder="0"> </iframe>
</div>

var app = angular.module('my-app', []);
app.controller('AppController', function ($scope, $sce) {  
    $scope.videoID = $sce.trustAsResourceUrl('http://www.youtube.com/embed/C0DPdy98e4c');
});

请参阅本文档.

这篇关于带有 iframe 的 AngularJs的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆