Importing variables in Typescript

Hi i’m having trouble importing variables.

export class LandPage {
bool1: boolean = false; }


import {LandPage} from './page1';
export class HomePage {
LandPage.bool1 = true;

Is it supposed to work? Because it’s not working. there’s a red underline on bool1 in page2. it says when i hover mouse

Property 'bool1' does not exist on type 'typeof LandPage'

i need them to ngbind into ionic on homepage. but i cant import them



export class LandPage {
   // bool1: boolean = false; 
  static bool1: boolean = false;

More about classes:

This is a bad idea. You should not be accessing the internals of one page from another; it makes for code that is needlessly difficult to read, maintain, and test.

Instead use a shared service or NavParams for this purpose.

1 Like

ah i see. okay i’ll try that first. thank you

Also, the notion of a static class feels anti-Angular to me. If you want a global state, build a provider that manages that global state. Then the local page injects the provider and asks it questions, etc.

1 Like