Angular 9 to Angular 11 Initialize observable

Viewed 831

In the order to create an Observable in Angular 9, i must just write this :

export class CreateEntityComponent implements OnInit {

uploadPercent: Observable<number>;

constructor() {  }

}

How i can change my code ? Thanks

But in Angular 11 i have this error in ititialization :

Property 'uploadPercent' has no initializer and is not definitely assigned in the constructor.
1 Answers

uploadPercent is still null because you've only declared the type. If you are defining it elsewhere in the component you can use uploadPercent!: Observable<number>;

Related