Custom Students Service

Learn how to display data on a page using services.

Before you flesh out the Roster page, you need to get some students to display. Later you will want to tie the list into a data store of some sort, but you do not need to do that just to get some data displayed on the page.

Angular services

For that, you are going to create a simple “Students” service you can inject into the pages that need it. Use the command line to create the service.

Angular CLI

In this case, it does not matter whether or not you use the Angular CLI or the Ionic CLI. Go ahead and use the Angular CLI this time. Enter the following command.

npx ng generate service Students --dry-run

In case this is your first time seeing npx, I will explain. When you install npm packages globally, as you did with the Ionic CLI, the package’s main binary will be linked to a folder that is already in your execution path.

On the other hand, the Ionic-Angular ...