点击按钮“推”我需要打开新窗口并传递给它HTML内容以显示它。
以下是显示HTML的视图:
这是控制器定义:
var test = angular.module('test', []);
test.controller('testController', ['$compile', '$scope','$window', function($compile, $scope, $window) {
$scope.openWindow = function() {
$window.open('to-print', 'width=500,height=400');
};}]);
这是HTML内容:
<div ng-app="test" id = "content" ng-controller="testController">
<label>Entar Name:</label>
<label>Michael</label>
<br/>
<br/>
<label>Entar Age:</label>
<label>25</label>
<hr/>
<button ng-click="openWindow()">push!</button>
</div>
我要在打开的窗口中显示的HTML是:
<label>Entar Name:</label>
<label>Michael</label>
<br/>
<br/>
<label>Entar Age:</label>
<label>25</label>
这是fiddle。
我该如何实施?
答案 0 :(得分:1)
答案 1 :(得分:1)
您可以在 documet.write()功能
中加入您的内容<script>
function myFunction() {
var myWindow = window.open("", "","width=600,height=100");
myWindow.document.write("<label>Entar Name:</label><label>Michael</label><br/><br/><label>Entar Age:</label><label>25</label>");
}
</script>