I\'m learning new angular from the tutorial(https://angular.io/tutorial/toh-pt4#inject-message-service). I\'m stuck in this while running the application after adding the Servic
From your code it looks like you are following Angular official guide which is based on Angular 6 and Rxjs 6. There is a breaking change in Rxjs for which you have to import operators
and Observable
in a different way now .
In Rxjs 6 the import is like below -
import { Observable, of } from 'rxjs'; // only need to import from rxjs
But as you are using Angular 5.2.x most probably you are still using Rxjs 5x version. Due to which your import statement should be like below
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/observable/of';
// or
import { of } from 'rxjs/observable/of';
Check the below link for complete changelog and instruction to install a compatibility package rxjs-compat
for upgrading from angular 5 to 6.
See this link for reference : https://www.academind.com/learn/javascript/rxjs-6-what-changed/