Skip to content

Instantly share code, notes, and snippets.

@llucasshenrique
Created February 1, 2018 15:52
Show Gist options
  • Save llucasshenrique/18d0b0dc1f25f15cf01ed28adb246a55 to your computer and use it in GitHub Desktop.
Save llucasshenrique/18d0b0dc1f25f15cf01ed28adb246a55 to your computer and use it in GitHub Desktop.
/**
*
* 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