wstudiokiwi
wstudiokiwi

Reputation: 900

Change element style from controller Ionic 2

My code:

document.querySelector(".myTabs .line")[0].style.left = '30%' ;

By i have error

undefined is not an object (evaluating 'document.querySelector(".myTabs .line")[0].style')

How i can change css style from controller?

Upvotes: 6

Views: 5275

Answers (1)

Duannx
Duannx

Reputation: 8726

document.querySelector will return the first element match with type is Element. You need to convert it to HTMLElement. Try this:

let elm = <HTMLElement>document.querySelector(".myTabs .line");
elm.style.left = '30%'

Upvotes: 7

Related Questions