The ng_content tag is used as a placeholder to display dynamic content. This placeholder tag is replaced with the original content as the template is parsed. The ng-content creates components that can be configured depending on the needs of the user.
Decorators are functions that are invoked with a prefixed @ symbol and immediately succeeded by a class; parameter; method or property. The decorator function is supplied data about the class; parameter or method; and the decorator function returns something in its place or manipulates its target in some way. Usually; the “something” a decorator returns is the same thing that was passed in; but it has been augmented in some way.
.subscribe is a method of rxjs library that Angular uses internally to observe the Observable objects. Calling .subscribe() method returns a Subscription object that has an unsubscribe() method; which can be used to stop receiving notifications.
Here are some of the differences between ActivatedRoute and RouterState with reference to Angular 2:-
– ActivatedRoute consists of the information about a route associated with a component loaded in an outlet. Whereas; RouterState represents the state in which the writer actually is.
– We need ActivatedRouteSnapchat to traverse all the activated routes. Whereas; during a navigation; after redirects have been applied; the router creates a RouterStateSnapshot.
– ActivatedRouteSnapshot has old data. When route changes; ActivateRouteSnapshot has data from previous route. Whereas; the RouterState cares about application components; or; to be more specific; about their arrangements.