# Pass variable through MyApp to pages

**URL:** <https://forum.ionicframework.com/t/pass-variable-through-myapp-to-pages/51376>\
**Category:** ionic-v3\
**Created:** [May 6, 2016, 4:14pm UTC](https://forum.ionicframework.com/t/pass-variable-through-myapp-to-pages/51376 "2016-05-06T16:14:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Grork](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/grork/32/139467_2.png) [@Grork](https://forum.ionicframework.com/u/Grork)\
**Post date:** [May 6, 2016, 4:14pm UTC](https://forum.ionicframework.com/t/pass-variable-through-myapp-to-pages/51376/1 "2016-05-06T16:14:10Z")

</div>

Hello,  
I’m using today Ionic 2 for the first time and I’m new to A2 ( I always developed with 1.x ).

I’m trying to pass a variable “countChat” from the class MyApp to a page, but without success.

**/app/app.js**

```
class MyApp {
    
  static get parameters() {
    return [[IonicApp], [Platform], [MenuController]];
  }

  constructor(app, platform, menu) {
    // set up our app
   [...]

    // set our app's pages
   [...]

    // make HelloIonicPage the root (or first) page
    [...]
    this.countChat = 3;

```

**/app/pages/[page-name]/[page-name].html**

`<div>{{ countChat }}</div>`

This is the code, but in the page nothing is showed.

Thanks!

---

<div class="post-metadata">

**Author:** ![allpref](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/allpref/32/99763_2.png) [@allpref](https://forum.ionicframework.com/u/allpref)\
**Post date:** [May 6, 2016, 4:53pm UTC](https://forum.ionicframework.com/t/pass-variable-through-myapp-to-pages/51376/2 "2016-05-06T16:53:30Z")

</div>

is better you put all the Chat vars and functions in a provider, take a look in the conferece app how its works.

> **[ionic-team/ionic-conference-app](https://github.com/ionic-team/ionic-conference-app)**
>
> ionic-conference-app - A conference app built with Ionic to demonstrate Ionic

---

<div class="post-metadata">

**Author:** ![Grork](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/grork/32/139467_2.png) [@Grork](https://forum.ionicframework.com/u/Grork)\
**Post date:** [May 7, 2016, 11:34am UTC](https://forum.ionicframework.com/t/pass-variable-through-myapp-to-pages/51376/3 "2016-05-07T11:34:06Z")

</div>

Thanks. Now I can see the OOP logic of TypeScript 🙂
