将canvas元素添加到div - Angular 4

时间:2017-12-01 14:29:38

标签: html5 angular canvas

我有一个角度4应用程序。在我的一个场景中,用户将tiff文件上传到服务器。要在浏览器中显示文件的预览,我使用Tiff.js库来生成html canvas元素。似乎一切都适用于下面的代码片段。我成功地获得了canvas对象。

this.image = myReader.result;
var tiff = new Tiff({buffer: loadEvent.target.result});
var canvas = tiff.toCanvas();
//document.body.append(canvas);
this.tiffCanvas = canvas;

但是我在页面中显示canvas元素时遇到了困难。这是我的HTML:

<div id="tiffCanvasContainer" [innerHtml]="tiffCanvas"></div>

它只是向页面打印[object HTMLCanvasElement]。 如何成功在页面中显示生成的画布?

1 个答案:

答案 0 :(得分:1)

//creating a resultset + connecting with the connection method and typing in query
ResultSet rowCount = MainApp.dataBaseSelect("SELECT COUNT(isFoundStatus) FROM damageclaim");

//creating int variable but needs a value since in later row it says ' might not be initalized '
int rowCountInt = 0;

//giving the resultset to the int.
while (rowCount.next()){
    rowCountInt = rowCount.getInt("isFoundStatus");
}
//testing with system out
System.out.println(rowCountInt);