How to set tag to ionic components

Hi friends, I am basically android developer start ionic framework. In android have view set-tag and get-tag option to set some data to view and get the data based on the requirement. So is any way to set data to components and get that data. example , i have image component set tag Boolean value and get Boolean value on particular scenario. how can handle this ?.

You can set any value as a BehaviorSubject(RxJS) and get the data or subscribe the data.
Example:


// a is an initial value. if there is a subscription 
// after this, it would get "a" value immediately
let bSubject = new BehaviorSubject("a"); 

bSubject.next("b");

bSubject.subscribe(value => {
  console.log("Subscription got", value); // Subscription got b, 
                                          // ^ This would not happen 
                                          // for a generic observable 
                                          // or generic subject by default
});

bSubject.next("c"); // Subscription got c
bSubject.next("d"); // Subscription got d

If you try to think in terms of “how would I do this in a Java Android app”, you are going to get extremely frustrated very quickly. Forget everything you know about native Android development and study Angular instead.

1 Like