Closed lava0208 closed 2 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; } }
did you get that working?
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;
public webcamImage: WebcamImage | undefined;
Cheers
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; } }