1

I am upgrading an application from AngularJS (v 1.5) to a new version of Angular

Acording to the documentation to proceed to the upgrade $rootScope it is not available in the recent versions. I already removed the $apply() but I have some doubts about removing $new. Is there any equivalent to $new in Angular2+ ?

My doubt is specific to $new

saomi
  • 855
  • 5
  • 16
  • 38
  • Possible duplicate of [Alternative to $scope in Angular 2.0](https://stackoverflow.com/questions/26921058/alternative-to-scope-in-angular-2-0) – georgeawg Sep 21 '18 at 11:53

3 Answers3

1

peterK $rootscope is used to for data sharing in angularjs. for data sharing in further versions you have to use services. for best solution refer following link https://angularfirebase.com/lessons/sharing-data-between-angular-components-four-methods/

Anuj
  • 11
  • 3
1

All the $scope concept should be removed.

apply is not relevant since the change detection is almost always automatic (in some specific cases you should be using the NgZone instead).

In general you should use shared service for what you want to do now (sharing data and logic among components).

More information in this answer

David Faure
  • 1,336
  • 14
  • 25
1

If you have $rootScope.$new() function used in AngularJS it could be probably migrated into separated child component in Angular2.

There is no equivalent for this function in Angular2 but the concept is to make separated context for e.g. for modal, tooltip, or any other element.

Karol Trybulec
  • 1,056
  • 1
  • 11
  • 17