NgModel not working


#1

I am facing very strange issue. I am using ngModel for 2 way data binding and its not working as expected other than in root page.

Any other page where I make use of ngModel for 2 way binding, it does not update the view at all. However, in the console, i can clearly see the values are being passed on.

Can anybody explain why its happening?


#2

Can you show the code where it doesn’t work as expected?
We might spot a mistake that you didn’t see.


#3

I have created a blank page, as my root page. I am using admob free plugin to show interstitial ad. When interstial ad is closed, i am redirecting to main page (Home page).

This is the code in blank page.

ionViewCanEnter() {    
    this.admob.showInterstitialAd()
      .then(x => x.take(1).subscribe(y => {
        this.navCtrl.push(HomePage)       
      }));
    return false;
  }

I have searched through entire forum and it seems after redirection my Home Page is not Zone aware, so definitely i am doing redirection in wrong way and unable to figure out, how to redirect it in right away, so that ng model should work after redirection


#4

And what does this have to do with ngModel?


#5

In the home page, i have a calculator. So when the key is pressed, I am setting input value in UI using ngModel.

All works good if I use it as root page, but after redirection, nothing works. I tried to use Ngzone to detect changes on key press and it works fine. But this is not the right approach to use ngZone in every single app in multiple locations.


#6

ngModel is taking value from where ? could you share home page code


#7

I will try to create repo and share the link


#8

Just created repo for the issue. I have set blank page as root page with admob interstitial, you can see after redirection ngModel not working at all.

But if you set home page as root page, then ngModel works fine.

Admob Issue Repo


#9

demo video of issue.