我想显示图片,但我得到[对象HTMLImageElement]。如何从[object HTMLImageElement]获取图片。
提前致谢。
html代码:
<div id = "test" ng-model="newpost.text" placeholder="Enter text here..." class="jjhtext" ng-keypress="restrictKeyPressJJH()" contenteditable = "true"></div>
<div class="row">
<div class="col-sm-6">
<a class="tab-item" ng-click="showstickers()">
<i class="icon ion-happy"></i>
</a>
</div>
<div class="col-sm-6" style="padding-top: 5px;">
<span style="margin-left: 200px;">{{300 - newpost.text.length}} left</span>
</div>
</div>
这是js代码:
$scope.getStickername = function(sticker){
if($scope.newpost.text === undefined){
$scope.newpost.text = " ";
}
console.log("sticker name"+sticker.sticker_name);
console.log("sticker img"+sticker.sticker_img);
var oImg=document.createElement("IMG");
oImg.src=sticker.sticker_img;
oImg.setAttribute("height", "20");
oImg.setAttribute("width", "15");
oImg.setAttribute("alt", "Smiley");
console.log(typeof(oImg));
console.log(JSON.stringify(oImg));
$scope.newpost.text = document.getElementById("test").appendChild(oImg);
console.log($scope.newpost.text);
}