如果离子开关处于模式,Ionic2[(ngModel)]将冻结ionic

如果离子开关处于模式,Ionic2[(ngModel)]将冻结ionic,ionic2,Ionic2,我在模式页面中有一个的代码,但当我转到该页面时,它会冻结,我需要将其关闭以使其重新工作。当我不使用装订时,显示正确。同一页上有一个使用ngModel的表单 <ion-item> <ion-label>public</ion-label> <ion-toggle (ionChange)="togglePublic()" [(ngModel)]="newComment.public"></ion-toggle> </ion-i

我在模式页面中有一个
的代码,但当我转到该页面时,它会冻结,我需要将其关闭以使其重新工作。当我不使用装订时,
显示正确。同一页上有一个使用
ngModel
的表单

<ion-item>
  <ion-label>public</ion-label>
  <ion-toggle (ionChange)="togglePublic()" [(ngModel)]="newComment.public"></ion-toggle>
</ion-item>

没有错误消息吗?没有,chrome选项卡只是冻结了,我需要在一个新的选项卡中重新打开它,重新加载页面不起作用。开发者控制台什么也没说?然后,您必须显示更多代码。组件的HTML和TS不,控制台中没有任何内容,Chrome甚至会提示页面没有响应。如果Chrome提示页面没有响应,则表示您进入了一个循环。我想您可能需要检查是否删除了this.authService并将“test”和this.originalTime放在“12:00”位置,如果可以的话,您知道问题出在哪里:)没有错误消息吗?没有,chrome选项卡只是冻结了,我需要在新选项卡中重新打开它,重新加载页面不起作用。开发人员控制台什么也没说?然后,您必须显示更多代码。组件的HTML和TS不,控制台中没有任何内容,Chrome甚至会提示页面没有响应。如果Chrome提示页面没有响应,则表示您进入了一个循环。我想您可能需要检查是否删除了this.authService并将“test”和this.originalTime放在那里,然后将“12:00”放在一起,如果它起作用,您知道问题出在哪里:)
<ion-content padding>
  <ng-container *ngIf="timer">
    <ng-container *ngIf="addingComment">
      <ion-card-header text-center class="new-comment">
        {{newComment.author}}
      </ion-card-header>
      <ion-card-content>
        <form [formGroup]="commentGroup">
          <ion-textarea placeholder="" clearInput formControlName="comment" [(ngModel)]="newComment.message"></ion-textarea>
          <ion-item *ngIf="commentGroup.controls['comment'].hasError('minlength') && commentGroup.controls.comment.touched" class="invalid">
            <p>The comment needs to be at least 4 characters</p>
          </ion-item>

          <ion-item *ngIf="commentGroup.controls['comment'].hasError('maxlength') && commentGroup.controls.comment.touched" class="invalid">
            <p>The max lengt is 140 characters</p>
          </ion-item>

          <ion-item *ngIf="commentGroup.controls['comment'].hasError('required') && commentGroup.controls.comment.touched" class="invalid">
            <p>A comment is required!</p>
          </ion-item>
        </form>
        <ion-item>
          <ion-label>public</ion-label>
          <ion-toggle (ionChange)="togglePublic()" [(ngModel)]="newComment.public"></ion-toggle>
        </ion-item>
        <p class="text-center">{{sToTime(newComment.time)}}</p>
        <ion-buttons end>
          <button (tap)="cancelComment()" color="danger" ion-button small>cancel</button>
          <button (tap)="postComment()" ion-button small>post</button>
        </ion-buttons>
      </ion-card-content>
    </ng-container>
    <ion-card *ngFor="let comment of commentsToDisplay" class="comment ">
      <ng-container *ngIf="!comment.remove && !comment.addComment">
        <ion-card-header class="text-center">
          {{comment.author}}
        </ion-card-header>
        <ion-card-content>
          <p>{{comment.message}}</p>
          <p class="text-center">{{sToTime(comment.time)}}</p>
        </ion-card-content>
      </ng-container>
      <ng-container *ngIf="comment.remove && !comment.addComment">
        <div class="fadeout">
          <ion-card-header class="text-center">
            {{comment.author}}
          </ion-card-header>
          <ion-card-content>
            <p>{{comment.message}}</p>
            <p class="text-center">{{sToTime(comment.time)}}</p>
          </ion-card-content>
        </div>
      </ng-container>
    </ion-card>
  </ng-container>

</ion-content>
  constructor(public viewCtrl: ViewController, public navParams: NavParams, public authService: AuthService, public commentData: CommentData) {
    this.isSerie = navParams.get('isSerie');
    this.media = navParams.get('media');
    this.comments = [];
    this.commentsToDisplay = [];
    this.commentGroup = new FormGroup({ comment: new FormControl('', Validators.compose([Validators.required, Validators.minLength(4), Validators.maxLength(140)])) });
    this.forwardingTimer = Observable.timer(0, 250);
    this.newComment = {
      message: '',
      author: this.authService.currentUser.user_name,
      time: this.originalTime,
      public: true
    }
  }