nativescript-camera-plus
nativescript-camera-plus copied to clipboard
How to set Static Properties such as defaultCamera on Angular apps?
Hi guys from nstudio. I'm trying to set the defaultCamera
to 'front'
, but it doesn't work for me.
I've tried setting on the html, like so and nothing changes:
Attempt 1:
<CameraPlus defaultCamera="front"></CameraPlus>
Attempt 2:
class CaptureComponent {
defaultCamera: string = 'front';
// ...
}
<CameraPlus [defaultCamera]="defaultCamera"></CameraPlus>
Is there another way of doing that? Should I set while registering the Element, how to do so?
PS: For the time being, I've edited the source file, but I would like to set properly avoiding bugs while updating from npm.
node_modules/@nstudio/nativescript-camera-plus/camera-plus.common.js:63
Thanks
Your second approach should work, it's possible there is some timing work that can be improved/fixed here. Can you send over a zip of project to test with?
Have you been able to solve this?
Simple, use this method:
getCurrentCamera()
Attempt 1 should work as well, no? (Both 1 & 2 are not working for me as well)
using this.cam.toggleCamera()
on camloaded()
Attempt 1 should work as well, no? (Both 1 & 2 are not working for me as well)
Late to the party but for me it had to be done quite early in my code, it's for VueJS but still, I set the value for that static field before attempting to using the component
let CamPlusFront = require('@nstudio/nativescript-camera-plus').CameraPlus; CamPlusFront.defaultCamera = "front"; Vue.registerElement('CameraPlus', () => CamPlusFront);
this.cam.toggleCamera()
just works fine temporarily but as I minimize app and come back its gone to rear OR default camera.
`import { CameraPlus } from '@nstudio/nativescript-camera-plus';
CameraPlus.defaultCamera = 'front'`
Do this while import and it would work..!!