Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 908
wstudiokiwi Avatar asked Jun 28 '17 12:06

wstudiokiwi


1 Answers

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%'
like image 123
Duannx Avatar answered Nov 05 '22 08:11

Duannx