I am unable to manipulate the DOM in the file home.ts and I need to display data from health kit.
If I am right and it is not possible how do I “transfer” constructors to home.html so that I can.
Thanks!
More info: Ionic: Manipulating DOM in home.ts?
I have no idea what you’re taking about.
Sorry this is what I am talking about:
I have a constructor with variables:
export class HomePage {
constructor(public socialSharing: SocialSharing, public ga: GoogleAnalytics, public platform: Platform, public navCtrl: NavController, public splashScreen: SplashScreen, public healthKit: HealthKit, public localNotifications: LocalNotifications) {
I need to display data from healthKit
but I am unable to manipulate the DOM of home.html which I need to do.
What am I doing wrong or am I right that manipulating the DOM from home.ts is not possible and if that is true how can I use the constructor vairables in home.html
What do you mean by manipulate the DOM? Just write an HTML template. Please use words I would recognize if I read Angular or Javascript documentation.
You shouldn’t need to manipulate your DOM since you’re using Angular 2. You should look into the Angular documentation for topics like two way data-binding, property binding, etc
But if you still want to manipulate the DOM, you can use the regular JS functions like document.getElementById('HTMLElementID") or document.querySelector("#HTMLElementID")
Just make sure you do all DOM manipulations after the DOM has loaded, perhaps in ionViewDidLoad. if you do them in the constructor, you’ll get undefined values.
1 Like
Thank you that makes sense.