Skip to Main Content
Mastering TypeScript 3 - Third Edition
book

Mastering TypeScript 3 - Third Edition

by Nathan Rozentals
February 2019
Beginner content levelBeginner
694 pages
18h 4m
English
Packt Publishing
Content preview from Mastering TypeScript 3 - Third Edition

Rendering REST data

Now that we have the skeleton BoardListComponent in place, we can integrate with our BoardService, and query our /api/boards REST endpoint in order to fetch a list of boards to display. Our updates are as follows:

export class BoardListComponent implements OnInit { 
    boardList: IBoard[] = []; 
    constructor(private boardService: BoardService) { } 
    ngOnInit() { 
        this.boardService.getBoardsList() 
           .subscribe((result: IBoard[]) => { 
            this.boardList = result; 
        }); 
    } 
} 

Here, we have a property named boardList that holds an array of elements of type IBoard. We have then updated our constructor function to inject an instance of the BoardService service, and store it in a private variable named boardService. Our ngOnInit function then ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

The TypeScript Workshop

The TypeScript Workshop

Ben Grynhaus, Jordan Hudgens, Rayon Hunte, Matt Morgan, Wekoslav Stefanovski

Publisher Resources

ISBN: 9781789536706Supplemental Content