Thursday, 21 July 2016

Angular 2/Ionic 2 ngModel Dynamic Global Variable

Hi everyone I currently am attempting to use my ngModeled variable globally.

So far I have the following code snippet.

homepage.html

<ion-input type="text" value="" [(ngModel)]="databaseID"> 

homepage.ts

public databaseID;

These functions work and when I attempt to print the ngModeled data from the home.ts class it prints what has been entered by the user. However I am not sure how to call databaseID from another class. I have tried setting databaseID to global (globals are static and therefor this will not work).

Could you possibly explain a way that I may access this variable from a different class?

Some possible thoughts I had were dependency injection and using a providers. But I'm not sure what would be the best way to do so.



from Recent Questions - Stack Overflow http://ift.tt/29Ot2Ax
via https://ifttt.com/ IFTTT

No comments:

Post a Comment