解析HTMLImageElement对象

时间:2016-01-22 11:34:53

标签: javascript object ionic-framework

我想显示图片,但我得到[对象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);


}

0 个答案:

没有答案