如何使用html angularjs动态创建div元素内的canvas元素?

时间:2015-09-16 12:11:52

标签: jquery html css angularjs canvas

我想知道如何在元素中动态创建canvas标签,实际上我上传json文件(给我的图片网址)在我的html页面上显示3D / 2D图像,但是我&# 39; m无法显示我的图像,如果有一些高度和距离的画布标签,则图像显示正确。我得到了所有的div id,我只需要div中的那些画布设置。请让我知道怎么做?提前谢谢。

json:[{"name":"imageurl","value":"/images/Image1.nii"},{"name":"3d","value":"3d0"},{"name":"sliceX","value":"sliceX0"},{"name":"sliceY","value":"sliceY0"},{"name":"sliceZ","value":"sliceZ0"}, {"name":"imageurl","value":"/images/Image2.nii"}, {"name":"3d","value":"3d1"},{"name":"sliceX","value":"sliceX1"},{"name":"sliceY","value":"sliceY1"},{"name":"sliceZ","value":"sliceZ1"}]

所需的html将是: 在第一次:

 <div ng-repeat="item in vals" data-imgsrc="/images/Image1.nii">
    <div id="3d0"><canvas height="150" width="130"></div>
    <div id="sliceX0"><canvas height="160" width="135"></div>
    <div id="sliceY0"><canvas height="150" width="130"></div>
    <div id="sliceZ0"><canvas height="160" width="135"></div>
    </div>

第二次:

<div ng-repeat="item in vals" data-imgsrc="/images/Image2.nii">
<div id="3d1"><canvas height="150" width="130"></div>
<div id="sliceX1"><canvas height="150" width="130"></div>
<div id="sliceY1"><canvas height="160" width="135"></div>
<div id="sliceZ1"><canvas height="160" width="135"></div>
</div>

0 个答案:

没有答案