nstudio / nativescript-camera-plus

MIT License
79 stars 50 forks source link

How to set Static Properties such as defaultCamera on Angular apps? #28

Open leocaseiro opened 6 years ago

leocaseiro commented 6 years ago

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

bradmartin commented 6 years ago

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?

marcelofb commented 5 years ago

Have you been able to solve this?

AklsKiu commented 5 years ago

Simple, use this method:

getCurrentCamera()

wimva commented 5 years ago

Attempt 1 should work as well, no? (Both 1 & 2 are not working for me as well)

myst-al commented 5 years ago

using this.cam.toggleCamera() on camloaded()

fumpierrez commented 4 years ago

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);

adityadi98 commented 3 years ago

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..!!