import Controller from '@ember/controller'; import { inject as service } from '@ember/service'; export default Controller.extend({ store : service(), didValidate: false, onSuccess: function(imageURI) { var image = document.getElementById('pictureResult'); console.log(imageURI); window.resolveLocalFileSystemURL(imageURI, function success(fileEntry) { image.src = fileEntry.toInternalURL(); }); }, onFail: function(message) { alert('Failed because: ' + message); }, init() { this._super(...arguments); }, actions: { saveNewsAndInformation() { this.get('model') .validate() .then(({ validations }) => { this.set('didValidate', true); if (validations.get('isValid')) { this.get('model').save().then(response => { if (response != undefined) { this.transitionToRoute('grade.detail', response.id); } }); } }); }, takePicture() { navigator.camera.getPicture(this.onSuccess, this.onFail, { quality: 50, destinationType: navigator.camera.DestinationType.FILE_URI }); } } });