Walkthrough tutorial step 12 - app.component.ts incorrect
Closed this issue · 1 comments
blong824 commented
Information
https://ngrx.io/guide/store/walkthrough
Step 12. src/app/app.component.ts
class AppComponent implements OnInit {
books$ = this.store.select(selectBooks);
bookCollection$ = this.store.select(selectBookCollection);
...
constructor(private booksService: GoogleBooksService, private store: [Store](https://ngrx.io/api/store/Store)) {}
Calling this.store outside of the constructor is throwing errors.
The following code works correctly:
class AppComponent implements OnInit {
books$: Observable<Book>();
bookCollection$: Observable<Book>();
...
constructor(private booksService: GoogleBooksService, private store: [Store](https://ngrx.io/api/store/Store)) {
this.books$ = this.store.select(selectBooks);
this.bookCollection$ = this.store.select(selectBookCollection);
}
Documentation page
No response
I would be willing to submit a PR to fix this issue
- Yes
- No
markostanimirovic commented
Hi @blong824,
There is no error. This is valid syntax. Check the StackBlitz playground: https://stackblitz.com/run?file=src%2Fapp%2Fapp.component.ts