February 2017
Beginner to intermediate
294 pages
6h 9m
English
We can create a service to return those hard-coded values inside the heading property. To do so, create a new TypeScript class named collector.service.ts and add the following contents to it:
// app/collector/collector.service.ts
export class CollectorService {
getHeadlines(): string[] {
return [
"Lorem ipsum dolor sit amet",
"consectetuer adipiscing elit",
"Integer tincidunt Cras dapibus",
"Quia dolori non voluptas "
];
}
}
Nothing special is happening here. This is an ordinary class with a simple method, which returns an array of strings. This is the simplest form of creating a class for our collector service. You may have noticed we didn't import any other modules or add any decoration to this class. We will improve it ...
Read now
Unlock full access