1

By click on button "push" I need to open new window and pass to it HTML content to display it.

Here is view that display HTML:

enter image description here

Here is controller definition:

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');
    };}]);

Here is HTML content:

<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>

And the HTML I want to display inside opened window is:

<label>Entar Name:</label>
<label>Michael</label>
<br/>
<br/>
<label>Entar Age:</label>
<label>25</label>

Here is fiddle.

How can I implement it?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Michael
  • 13,950
  • 57
  • 145
  • 288
  • 1
    Please refer the below links. http://stackoverflow.com/questions/28553547/send-angularjs-variables-to-new-popup-window http://stackoverflow.com/questions/22921262/angularjs-issue-passing-data-to-a-new-browser-window-on-internet-explorer – Aravind Jun 13 '16 at 12:46

2 Answers2

2

You can include your content in documet.write() function

<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>
Aravinthan K
  • 1,763
  • 2
  • 19
  • 22
1

It's very simple... Add after

.open()

the following code

.document.write("Lorem Ipsum");

Here is a jsfiddle