From the course: Angular: Progressive Web Apps

Unlock the full course today

Join today to access over 24,000 courses taught by industry experts.

Creating services: Data

Creating services: Data

- [Instructor] Now it's time for our second injectable service. So I'm going to open the terminal again and we're going to generate another service. I'm going to say, ng generate service, and the name is going to be data. In this service, we're going to store the data about the coffees, and we will use it later as a proxy, as a bridge, to our web server, to our backend. So now I have the data.service.ts ready. Let's open the file, close the terminal window, and start typing the data service. In this case for the data service, I'm going to start with just one function, one method with the name getList. GetList will actually be responsible for returning the list of coffees. So I'm going to create for now, only for now, a hard-coded list of coffees. Later we'll connect this to a backend. So I'm going to create an array of coffees. So I'm going to create a new coffee and the coffee needs a name, a place, and an…

Contents