Skip to content

Commit

Permalink
fix(watch): change orchestration of calls to please change detection
Browse files Browse the repository at this point in the history
dev mode check two times the dom. It causes problem with nested bindings

(http://stackoverflow.com/questions/34364880/expression-has-changed-after-it-was-checked/34364881#34364881).

The current implementation work around that in dev mode

Fixes #66
  • Loading branch information
MathieuNls committed Nov 2, 2016
1 parent 263f73d commit 2191edd
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 19 deletions.
3 changes: 1 addition & 2 deletions src/components/mobile-error/mobile-error.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<div class="form-group">
<div *ngFor="let error of errors"
class="error-message">
<div *ngFor="let error of errors" class="error-message">
{{ error | translate }}
</div>
</div>
2 changes: 1 addition & 1 deletion src/components/mobile-input/mobile-input.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
[formControl] = "control"
[(ngModel)] = "value"
(ngModelChange) = "valueChange.emit($event);"
[ngClass] = "{'ng-not-empty': (value || 0 !== value.length)}"
[ngClass] = "{'ng-not-empty': (value== null || value || 0 !== value.length)}"
>

<span class="highlight"></span>
Expand Down
5 changes: 3 additions & 2 deletions src/components/mobile-input/mobile-input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,10 @@ export class MobileInput {
/**
* Pull the brands
*/
ngAfterViewInit() {
ngOnInit() {

if(this.control == null || this.id == null){
if(this.control == null || this.id == null
|| this.control == undefined || this.id == undefined){
throw "[Control] and [id] must be set";
}

Expand Down
16 changes: 3 additions & 13 deletions src/pages/watch/watch.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AlertController, NavController, NavParams} from 'ionic-angular';

import {Component} from '@angular/core';
import {Component, Output, EventEmitter} from '@angular/core';
import { FormBuilder } from '@angular/forms';

import {
Expand All @@ -21,9 +21,7 @@ export class WatchPage extends WatchComponent {

background:string = "addWatch-background";
slogan:string ="add-new-watch";
errors = [
{flag:this.error, label:"error"}
];
errors = [];

constructor(
//Own injections
Expand Down Expand Up @@ -51,17 +49,9 @@ export class WatchPage extends WatchComponent {
}
);

//The view is used for edit and create watches both.
//Here, we check if we received a watch and adapt the
//textual context of the view.
let receivedWatch:Watch = this.navParams.get('watch');
console.log(this.navParams.get('watch'));
if (receivedWatch !== undefined){
this.watchModel = receivedWatch.clone();

this.watchModel = receivedWatch.clone();
this.slogan = "edit-watch";
this.initForm();
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/share
Submodule share updated from 96f57d to 1c09e2

0 comments on commit 2191edd

Please sign in to comment.