Issue
I am trying to access android’s R
object in NativeScript with Angular but I haven’t had any success. The instructions here say to do it like this:
android.R.color.holo_purple
But when I try to import the android
variable from the application
module or the tns-core-modules/platform
module I get an error that the R
property on the android
object is undefined. How do I get access to R
?
Solution
you don’t need to import android
variable from application
module. it is automatically available by default at runtime. to remove compile time error property doesn't exists
just declare the variable named android
to any
.
for example.
declare var android:any;
export class AppComponent{
let holoPurple=android.R.color.holo_purple;
}
Answered By – bhavin jalodara
Answer Checked By – Pedro (AngularFixing Volunteer)