meteorangularangular2-meteor

Passing value between two components in angular2-meteor project


I am using angular2-meteor.

When I try to pass a value between two components (when the value change in the first component, create an event in second component and use this new value), I have two ways right now:

  1. One way is meteor way: using this.autorun and Session.get.
  2. Another way is angular2 way: using Injectable service with EventEmitter.

Which way should be prior? Or is there any other better way? Thanks


Solution

  • Now I used angular2-meteor a while.

    Although the angular2-meteor tutorial has no example so far about using or choosing Angular 2 service or Meteor Session.

    But I feel angular 2 takes the lead in the front end, while meteor makes reactivity easier and also handle all back end things.

    So I went with angular2 way using service to share between components. And service is very powerful like @todd-w-crone said.

    If anyone has better answer, I will switch to accept that one.