Skip to content
This repository has been archived by the owner on May 4, 2022. It is now read-only.

fix(AlertComponent): check if d.buttons and d.inputs is defined #936

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/components/alert/alert-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { AlertButton, AlertInputOptions, AlertOptions } from './alert-options';
'<h3 id="{{subHdrId}}" class="alert-sub-title" *ngIf="d.subTitle" [innerHTML]="d.subTitle"></h3>' +
'</div>' +
'<div id="{{msgId}}" class="alert-message" [innerHTML]="d.message"></div>' +
'<div *ngIf="d.inputs.length" [ngSwitch]="inputType">' +
'<div *ngIf="d.inputs && d.inputs.length" [ngSwitch]="inputType">' +

'<ng-template ngSwitchCase="radio">' +
'<div class="alert-radio-group" role="radiogroup" [attr.aria-labelledby]="hdrId" [attr.aria-activedescendant]="activeId">' +
Expand Down Expand Up @@ -58,7 +58,7 @@ import { AlertButton, AlertInputOptions, AlertOptions } from './alert-options';
'</ng-template>' +

'</div>' +
'<div class="alert-button-group" [ngClass]="{\'alert-button-group-vertical\':d.buttons.length>2}">' +
'<div *ngIf="d.buttons && d.buttons.length" class="alert-button-group" [ngClass]="{\'alert-button-group-vertical\': d.buttons.length > 2}">' +
'<button ion-button="alert-button" *ngFor="let b of d.buttons" (click)="btnClick(b)" [ngClass]="b.cssClass">' +
'{{b.text}}' +
'</button>' +
Expand Down Expand Up @@ -134,14 +134,14 @@ export class AlertCmp {
// normalize the data
const data = this.d;

data.buttons = data.buttons.map(button => {
data.buttons = data.buttons ? data.buttons.map(button => {
if (typeof button === 'string') {
return { text: button };
}
return button;
});
}) : [];

data.inputs = data.inputs.map((input, index) => {
data.inputs = data.inputs ? data.inputs.map((input, index) => {
let r: AlertInputOptions = {
type: input.type || 'text',
name: isPresent(input.name) ? input.name : index + '',
Expand All @@ -156,7 +156,7 @@ export class AlertCmp {
max: isPresent(input.max) ? input.max : null
};
return r;
});
}) : [];


// An alert can be created with several different inputs. Radios,
Expand Down