February 2017
Beginner to intermediate
294 pages
6h 9m
English
Let's start by creating an empty service and creating a very basic structure for its functions. Create a new TypeScript file inside the evidence/ folder and add the following contents to it:
// src/app/evidence/evidenc.service.ts
import {Injectable} from "@angular/core";
@Injectable()
export class EvidenceService {
private words = [ {key:"w1",value:1}, {key:"w2",value:2} ];
wordCounts(url) {
// ToDo: get a url subscribe to its response and call other
// functions to count the words and their occurrence in it.
// Ideally it will return an array of objects.
return words;
}
}
So the draft version of our service is very simple. It gets a URL which contains the article of our interest and then finds and returns all unique words ...
Read now
Unlock full access