【Cordova】iOSカメラ画像の表示

Onsen-UIがGUIベース
カメラを起動して撮った写真を画面表示するサンプル

事前にcamera permissionsプラグインをaddしないとアプリが強制終了されます。iOS8以降?

index.html
<template id="camera.html">
<ons-page>
camera.html
<div class="camapp">
<div>
<ons-button onclick="takePictures()">takePhoto</ons-button>
<div>
<img src="" id="image" width="300px"/>
</div>
</div>
</div>
</ons-page>
</template>

camera.js

var camapp = {
initialize: function(){
this.bindEvents();
},
bindEvents: function(){
document.addEventListener('devieready', this.onDeviceReady, false);
console.log("camera device ready");
},
onDeviceReady: function(){
var button = document.getElementById("take_pictures");
button.addEventListener("click", takePictures);
console.log("take picture ready");
}
};

camapp.initialize();

function takePictures(){
console.log(&quot;takePictures&quot;);
navigator.camera.getPicture(cameraSuccess, cameraError, {quality: 80, destinationType: Camera.DestinationType.FILE_URI});
}

function cameraSuccess(image){
console.log(&quot;takePictures success&quot;);
var srcPath = image;
$('#logCamerahtml').val(srcPath);
$('#image').attr('src', srcPath);
}