我的 HTML 页面如下所示:
<div>
<iframe margin="0" padding="0" border="none" width="420" height="345" frameBorder="0"
ng-src="{{exercise_video_url}}">
</iframe>
</div>
'exercise_video_url' 我在我的控制器中设置如下:
$http.get("https://localhost:8000/api/exercises/initial/").then(function(response){
$scope.initial_data=response.data;
angular.forEach($scope.initial_data, function(item){
$scope.exercise_type=item.exercise_type;
$scope.exercise_description=item.description;
$scope.exercise_video_url=$sce.trustAsResourceUrl(item.video_url);
})
我正在从我的 Django 视图中获取特定的运动相关信息,运动模型有一个 video_url 作为属性。我在某处阅读并在我的角度控制器中注入了 $sce 服务。
视频链接本身看起来像' https://youtu.be/ ******' --> * 是几个随机字符。如果您在浏览器中点击此链接或直接将其作为 ng-src 的来源,则此链接可以独立工作。
我还尝试在我的 settings.py 中 评论“ django.middleware.clickjacking.XFrameOptionsMiddleware ”