Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is ion-textarea, (ngModelChange) and setting value via [(ngModel)] broken? #9434

Closed
c3iq opened this issue Dec 1, 2016 · 1 comment
Closed

Comments

@c3iq
Copy link

c3iq commented Dec 1, 2016

Ionic version: (check one with "x")
[ ] 1.x
[x] 2.x

I'm submitting a ... (check one with "x")
[x] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or http://ionicworldwide.herokuapp.com/

Current behavior:

In an ion-textarea, setting a variable in (ngModelChange) in a function fired by(ngModelChange) only works once. That is the content of the textarea only gets updated once. 'characterRemaining' does get updated in the app.

I started with Ionic v2 two weeks ago. This is my first mobile app....

PS. With this current configuration 'maxlength' didn't seem to do anything, hence this effort.

Expected behavior:

The textarea should be updated every time the function changes the model variable.

Steps to reproduce:

Related code:

<ion-label>{{charactersRemaining}}</ion-label>
<form [formGroup]="viewForm" (ngSubmit)="submitView()">
    <ion-textarea type="text" placeholder="Enter your view here." [(ngModel)]="view.text" formControlName="viewTextArea" rows="6" (ngModelChange)="viewTextChange()"></ion-textarea>
    <button ion-button type="submit" block>Send</button>
</form>

I would expect that if the last line was uncommented the textarea would always display 'frank':

  public viewTextChange() {
    var left = this.viewMaxLength-this.view.text.length;

    if (left < 0) {
      this.view.text = '' + this.oldViewText;
      left = this.viewMaxLength-this.view.text.length;
    }

    this.charactersRemaining = (this.viewMaxLength-this.view.text.length) + ' characters remaining.';
    this.oldViewText = this.view.text;

    /* this.view.text = 'frank'; */
  }

Ionic info: (run ionic info from a terminal/cmd prompt and paste output below):

Cordova CLI: 6.4.0 
Ionic Framework Version: 2.0.0-rc.3
Ionic CLI Version: 2.1.13
Ionic App Lib Version: 2.1.7
Ionic App Scripts Version: 0.0.45
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Linux 4.8
Node Version: v4.6.1
Xcode version: Not installed

package.json:

{
  "name": "ionic-hello-world",
  "author": "Ionic Framework",
  "homepage": "http://ionicframework.com/",
  "private": true,
  "scripts": {
    "ionic:build": "ionic-app-scripts build",
    "ionic:serve": "ionic-app-scripts serve"
  },
  "dependencies": {
    "@angular/common": "2.1.1",
    "@angular/compiler": "2.1.1",
    "@angular/compiler-cli": "2.1.1",
    "@angular/core": "2.1.1",
    "@angular/forms": "2.1.1",
    "@angular/http": "2.1.1",
    "@angular/platform-browser": "2.1.1",
    "@angular/platform-browser-dynamic": "2.1.1",
    "@angular/platform-server": "2.1.1",
    "@ionic/storage": "1.1.6",
    "ionic-angular": "2.0.0-rc.3",
    "ionic-native": "2.2.3",
    "ionicons": "3.0.0",
    "rxjs": "5.0.0-beta.12",
    "zone.js": "0.6.26"
  },
  "devDependencies": {
    "@ionic/app-scripts": "0.0.45",
    "typescript": "2.0.6"
  },
  "cordovaPlugins": [
    "cordova-plugin-whitelist",
    "cordova-plugin-console",
    "cordova-plugin-statusbar",
    "cordova-plugin-device",
    "cordova-plugin-splashscreen",
    "ionic-plugin-keyboard"
  ],
  "cordovaPlatforms": [],
  "description": "DMUViews: An Ionic project"
}
@ionitron-bot
Copy link

ionitron-bot bot commented Sep 2, 2018

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Sep 2, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants