basst314 / ngx-webcam

A simple Angular webcam component / pure & minimal, no flash-fallback
https://basst314.github.io/ngx-webcam/?
MIT License
228 stars 104 forks source link

Type 'null' is not assignable to type 'WebcamImage' #128

Closed lava0208 closed 2 years ago

lava0208 commented 3 years ago

https://ibb.co/TcPSL6b

In app.component.ts I imported WebcamImage.

import {WebcamImage} from 'ngx-webcam';

As like the tutorial when I use this WebcamImage as public , it returns this error.

Type 'null' is not assignable to type 'WebcamImage'

what is the reason of this error?

Total code in here.

import { Component } from '@angular/core'; import {Subject, Observable} from 'rxjs'; import {WebcamImage} from 'ngx-webcam';

@Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.css'] }) export class AppComponent {

public webcamImage: WebcamImage = null; handleImage(webcamImage: WebcamImage) { this.webcamImage = webcamImage; } }

arkitektz-dev commented 2 years ago

did you get that working?

mbagusprasojo commented 2 years ago

You need to turn off strictNullChecks in your tsconfig to ignore the null checking OR You can just define it like this public webcamImage: WebcamImage | undefined;

Cheers