0

I’m looking for the equivalents of Angular’s $rootScope, $scope and $watch in Ionic 2 using TypeScript.

GergelyPolonkai
  • 6,230
  • 6
  • 35
  • 69
Jignesh M. Mehta
  • 904
  • 2
  • 12
  • 27
  • @GergelyPolonkai $rootScope, $scope and $watch are variables. in previous version of IONIC i used [link](http://stackoverflow.com/questions/22738482/angularjs-watch-root-scope-variable-for-changes). But it may different in the Typescript. so wanting to know equivalent. Thanks... – Jignesh M. Mehta Aug 03 '16 at 11:24
  • So you are migrating from Angular? – GergelyPolonkai Aug 03 '16 at 11:30
  • @GergelyPolonkai: Yes, some of issues are overcome in IONIC 2 with this reason want to use Ionic 2. – Jignesh M. Mehta Aug 03 '16 at 11:54
  • I have edited your question accordingly. However, it would be better if you could provide some additional details, like pieces of code you already wrote and not working as intended, or some signs of research you have done in the topic. – GergelyPolonkai Aug 03 '16 at 11:58
  • @GergelyPolonkai: i just got [This Example](http://stackoverflow.com/questions/35985009/angular-2-what-is-equivalent-to-root-scope/35985880#35985880) during research work. but it is not well enough. – Jignesh M. Mehta Aug 03 '16 at 12:05
  • By the way thanks @GergelyPolonkai – Jignesh M. Mehta Aug 23 '16 at 09:16
  • For equivalent to $rootScope look at this answer https://stackoverflow.com/a/44266176/4356754 – Mohamed Ali May 30 '17 at 15:35

2 Answers2

1

I dont know the exact equivalent but I have replaced it with the following:

$rootScope: Providers that handle the storage

export class AppGames {
    get GAME_NAMES(): any {
        return 'pizza/hut';
    }

$scope: this

export class BuyTopUpModalPage {
    dataList: any = [];
    constructor() {
      this.dataList = ['we', 'won']
    }

$watch: Observable

LeRoy
  • 4,189
  • 2
  • 35
  • 46
1

For equivalent to $rootScope, you can use base class for all components and place all shared vars and methods

look at this answer for more details

https://stackoverflow.com/a/44266176/4356754

Mohamed Ali
  • 3,717
  • 1
  • 33
  • 39