Created
February 1, 2018 15:52
-
-
Save llucasshenrique/18d0b0dc1f25f15cf01ed28adb246a55 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* | |
* Os cheboxes são gerados dinamimcamente a partir do array customTypes | |
* Exemplo do HTML responsável pelo Checkbox | |
*/ | |
` | |
<ion-item *ngFor="let customType of customTypes" (press)="editCustomType(customType)" > | |
<ion-label>{{customType?.name}}</ion-label> | |
<ion-label>{{customType?.description}}</ion-label> | |
<ion-checkbox color="customType?.color" (ionChange)="addType(customType)" [checked]="isChecked(customType)"></ion-checkbox> | |
</ion-item> | |
` | |
/** | |
* | |
* No typescript eu verifico se o checkbox em questão já foi adicionado a lista de selecionados, | |
* assim dinamicamente ao voltar para editar tenho informação sobre quais chekbox já estão marcados | |
* porém ao desmarcar um checkbox marcado o erro, ExpressionChangedAfterItHasBeenCheckedError, é lançado. | |
*/ | |
isChecked(customType: CustomType) { | |
let find: boolean = this.selectedTypes.some(find => { | |
return find.id == customType.id | |
}) | |
return find | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment