在Angular JS中使用iFrame
Using iFrame in Angular JS
我有两个不同的html页面。我想使用iframe将第二个显示为第一个。这两个html页面都在assets/templates/mainapp/下的grail-app文件夹中。我正在使用ngroute处理页面。
第一个html页面是
<!-- @author Karan Shah -->
<body>
<div>
<h1>Document Display Contents</h1>
<!-- Back -->
<a href="#/documents">Back to the List of Documents</a>
<!-- Get the name of the selected document from previous view to be displayed on current view -->
<br>
<div ng-controller='displaycontrol'>
You are viewing : <b>{{doc}}</b>
</div>
<!-- Http get request to get the text of the document to controller -->
<br>
<div ng-controller='textcontrol'>
{{textofdocument}}
</div>
<div>
<iframe ng-src="/maindocument.html">Fail</iframe>
</div>
</div>
</body>
HTML的第二个页面是(maindocument.HTML)
<!DOCTYPE html>
<html >
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
Hello how are you ??
</body>
</html>
控制器文件
/**
* @author Karan Shah
*
*/
var documentDisplayModule = angular.module('ald.documentdisplay',[]);
// Selected document name from previous view gets displayed on the document display view using $routeParams
documentDisplayModule.controller('displaycontrol',['$scope','$routeParams', function($scope,$routeParams){
$scope.doc=$routeParams.doc;
}]);
// $http.get to get the text based on the selected document
documentDisplayModule.controller('textcontrol',['$scope','$http','$routeParams',function($scope,$http,$routeParams){
$http.get("/document/getContents?docName="+$routeParams.doc).success(function(datatext){
$scope.textofdocument=datatext;
})
}])
documentDisplayModule.controller('framecontrol',['$scope',function($scope){
$scope.docurl="assets/templates/mainapp/maindocument.html";
}])
我想我没有把src做好。有人能告诉我应该是什么来源吗?我不能展示任何东西。这是我在调试时遇到的错误
GET http://localhost:8080/maindocument.html 404 (Not Found)
源应该位于文件夹中maindocument.html所在的位置
即。
assets/templates/mainapp/maindocument.html
使用-
<iframe src="assets/templates/mainapp/maindocument.html"></iframe>
相关文章:
- 如何使用Angular动态添加iframe-src
- 如何检测iframe是否在angular中完全加载
- 如何在angular js中使用滚动条打印iframe内容
- Angular IFrame ng-src: 插值误差
- iframe 中的 Angular js 作用域变量值
- 在 Angular JS 中检索 Iframe 中的数据绑定值
- 可以't获取从指令传递给Angular控制器的iframe元素
- 用Angular JS加载iframe src-错误
- Angular:Iframe指令中的src属性错误
- 如何使用$sce插入带有angular.js的iframe
- 如何在整个Angular应用程序中获得对Youtube Iframe API播放器的参考
- 在Angular JS中使用iFrame
- 使用ng-bind-html从Angular Array中生成Iframe视频
- Angular.js:在加载时改变Iframe的高度;改变的内容
- 在iframe中使用angular调用controller
- 获取angular的onload事件.iframe元素
- 表单在iframe中无法在Angular和IE11中重新获得焦点
- Angular 2中通过DOM改变iframe url的更好方法
- Angular和Firebase的数据使用iframe用于youtube等
- 在其他非angular应用的iframe中测试量角器