[Angular2] Using observables to bind value to a component out of data flow

58 views
Skip to first unread message

Carlos Esteban Lopez Jaramillo

unread,
Jan 17, 2016, 8:06:29 AM1/17/16
to AngularJS
Hi, i'm making a busy indicator component, the way i did go with it is to have the component right under the app html component side to side with the <router-outlet></router-outlet> component.

I need to be able to set a variable from anywhere in the code, so i was thinking about observables to send values to it, can't use the angular binding with EventEmitter since the busy component is outside of the components hierarchy.

Any idea how to set it up? i'm a noob about Rxjs, how do i create an observable of the variable and how would i call it from another component to set the value?
Message has been deleted

michael corbridge

unread,
Jan 17, 2016, 9:50:04 AM1/17/16
to AngularJS
Hey Carlos,

Streams are definitely the way to go in this case. Torgeir Helgevold (<- props to Torgeir!) has an excellent example of this at:

http://www.syntaxsuccess.com/viewarticle/pub-sub-in-angular-2.0

I know for a fact that this will do exactly what you are looking for.

 - michael

Carlos Esteban Lopez Jaramillo

unread,
Jan 17, 2016, 1:27:28 PM1/17/16
to AngularJS
@michael corbridge I also think streams is the way to go, i'm thinking of setting up the component and above an injectable, then set up an Observable in the injectable and subscribe to it in the component, who is it?

For the time being i will look to the link you advised me.

Carlos Esteban Lopez Jaramillo

unread,
Jan 17, 2016, 1:36:37 PM1/17/16
to AngularJS
Yup, definitely the way to go, but that one isn't using the new version 5 beta, right, i think i will have to find out how it works by try and error.


El domingo, 17 de enero de 2016, 9:50:04 (UTC-5), michael corbridge escribió:

Carlos Esteban Lopez Jaramillo

unread,
Jan 17, 2016, 2:19:28 PM1/17/16
to AngularJS
Yup, done, finally i can finish my app, thanks for the help, by the way, i'm using ionic 2 but this kind of question was more related to angular 2.


El domingo, 17 de enero de 2016, 9:50:04 (UTC-5), michael corbridge escribió:

michael corbridge

unread,
Jan 17, 2016, 2:24:02 PM1/17/16
to AngularJS
I need to start writing some Ionic... I hope their forum is as good as this one!

Carlos Esteban Lopez Jaramillo

unread,
Jan 17, 2016, 11:24:50 PM1/17/16
to ang...@googlegroups.com
It's pretty good, there's not so much people but they do try to help when they know about the subject, or at least the ones in the ionic 2 section.

--
You received this message because you are subscribed to a topic in the Google Groups "AngularJS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/angular/VStit1L-1qA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.



--
Carlos López
Ingeniero Desarrollador
Programador Full Stack
Skype: luchillo.lopez
Móvil: +57 305 295 3543
Medellín, Colombia
Reply all
Reply to author
Forward
0 new messages