Javascript 为什么我能';在新打开的窗口中看不到图标图标?

Javascript 为什么我能';在新打开的窗口中看不到图标图标?,javascript,html,angularjs,twitter-bootstrap,Javascript,Html,Angularjs,Twitter Bootstrap,我使用$window.open命令打开新窗口,并将html内容写入窗口 下面是Javascript代码: var test = angular.module('test', []); test.controller('testController', ['$compile', '$scope','$window', function($compile, $scope, $window) { $scope.openWindow = function() { $window.

我使用$window.open命令打开新窗口,并将html内容写入窗口

下面是Javascript代码:

var test = angular.module('test', []);

test.controller('testController', ['$compile', '$scope','$window', function($compile, $scope, $window) {
    $scope.openWindow = function() {
       $window.open('', '_blank', 'width=500,height=400').document.write($("#report").html());
    };}]);
以下是我在新窗口中写入的内容:

<div ng-app="test" id = "report" ng-controller="testController">
 <p>Envelope icon: <span class="glyphicon glyphicon-envelope"></span></p>
<p>Search icon: <span class="glyphicon glyphicon-search"></span></p>
<p>Print icon: <span class="glyphicon glyphicon-print"></span></p>
<hr/>
    <button ng-click="openWindow()">push!</button>
</div>

信封图标:

搜索图标:

打印图标:


这就是工作

问题是我在新打开的窗口中看不到glyphicon图标


知道我为什么看不到glyphicon图标吗?

您的代码中有两个错误。首先,您没有正确地包含css。您应该使用
href
属性而不是
rel
属性来包含css。其次,如果从外部包括引导,则必须使用
完整性
键检查

正确的包含方式如下:

var test = angular.module('test', []);

test.controller('testController', ['$compile', '$scope','$window', function($compile, $scope, $window) {
    $scope.openWindow = function() {
    var content = $("#report").html();

    var html = '<html><head><title>hi</title><link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous"></head><body>'+content+'</span></p></body></html>'   

       $window.open('', '_blank', 'width=500,height=400').document.write(html);                         
    };}]);

根据加载模板文件的方式(例如从后端),如果存在查询参数,则可以限制加载模板文件。

推送到新窗口的html中的链接错误。用这个代替


更新的fiddle

谢谢。但是如果我想引用我的项目中的样式表,而不是来自互联网,该怎么办?
$window.open('http://yoursite.com/page.html?window=true', '_blank', 'width=500,height=400');