When I click on one of the item under the list and go to the detail page, it throws ExpressionChangedAfterItHasBeenCheckedError and a DebugContext.
I was able to strip down my original project to plunker and reproduce the error. The error happens only with Textarea. If I replace Textarea with Input it is fine.
See the 3rd comment for a link and details of live example.
import { Component, Input, OnInit, OnDestroy } from '@angular/core';
import { Router, ActivatedRoute, Params } from '@angular/router';
import { BeginEventEmitter, EndEventEmitter } from './emitter';
import { SelectSourceService } from "./sourceselect.service";
import { CodeService } from "./codes.service";
import { Code } from "./code"
@Component(
{
selector: 'Detail',
template: ` <h3>Details</h3>
<form>
<div class="form-group">
<label for="id">ID</label>
<input type="text" class="form-control" id="id" name="id" [(ngModel)]="theCode.id">
</div>
<div class="form-group">
<label for="description">description</label>
<textarea class="form-control" id="description" name ="description" rows=10 cols=30 [(ngModel)]="theCode.description"></textarea>
</div>
<button type="button" class="btn btn-default" (click)="OnFormSubmit()">Submit</button>
</form>`
})
export class DetailsComponent implements OnInit, OnDestroy {
theCode: Code;
id: string;
showLoader: boolean = true;
source : string;
setDetail(): void {
this.theCode = this.codeService.getCode4Id(this.source, this.id);
}
constructor(private codeService: CodeService, private route: ActivatedRoute, private router: Router,
private _selSourceService: SelectSourceService, private opening:BeginEventEmitter, private closing:EndEventEmitter) {
}
ngOnInit()
{
this.route.params
.subscribe(value => this.id = value['id']);
this.subscription = this._selSourceService.sourceSelection$.subscribe((selection: string) => { this.source = selection; this.setDetail(); });
this.opening.emit("Opening Details for " + this.id);
}
ngOnDestroy() {
this.closing.emit("Closing Details for " + this.id);
}
OnFormSubmit(data: Code): void {
alert("The Changes were submitted");
this.router.navigate(['/Codes']);
}
OnFormCancel() : void {
alert("The form was cancelled");
}
};