File
Index
Properties
|
|
Methods
|
|
Inputs
|
|
Constructor
constructor(events: Events, modalCtrl: ModalController)
|
|
Parameters :
Name |
Type |
Optional |
events |
Events
|
No
|
modalCtrl |
ModalController
|
No
|
|
enableQuestionReadOut
|
Type : boolean
|
|
Methods
addOptionsToUrl
|
addOptionsToUrl(options, type: string)
|
|
Parameters :
Name |
Type |
Optional |
options |
|
No
|
type |
string
|
No
|
|
Async
openHint
|
openHint(hint)
|
|
|
pauseQuestion
|
pauseQuestion()
|
|
|
playQuestion
|
playQuestion(question, options, type)
|
|
Parameters :
Name |
Optional |
question |
No
|
options |
No
|
type |
No
|
|
play
|
Default value : false
|
|
showQuestionNumber
|
Default value : false
|
|
import { Component, Input } from '@angular/core';
import { Events } from '@app/util/events';
import { ModalController } from '@ionic/angular';
import { HintComponent } from '../hint/hint.component';
@Component({
selector: 'app-question-heading',
templateUrl: './question-heading.component.html',
styleUrls: ['./question-heading.component.scss'],
})
export class QuestionHeadingComponent {
text: string;
@Input() data;
@Input() inputIndex;
@Input() enableQuestionReadOut: boolean;
showQuestionNumber = false;
play = false;
constructor(private events: Events, private modalCtrl: ModalController) {
this.events.subscribe('speech', data => {
this.play = false;
})
}
playQuestion(question, options, type) {
this.play = true;
// this.textToSpeech.speechFromText({text:question}).then(success =>{
// let url = options.length > 0 ? this.addOptionsToUrl(options , type) :
// this.play = false;
// }).catch(error =>{
// console.log(JSON.stringify(error));
// });
}
addOptionsToUrl(options, type: string) {
// let url = type === 'multiSelect' ? 'you can select multiple options ' : 'select one option form following ';
// this.textToSpeech.speechFromText({ text: url }).then(async success => {
// // options.forEach( async (option,optionIndex) =>{
// for (let i = 0; i < options.length; i++) {
// let url = 'option ' + (i + 1) + options[i]['label'];
// await this.textToSpeech.speechFromText({ text: url }).then(success => {
// }).catch(
// error => {
// this.play = false;
// }
// );
// }
// this.play = false;
// }).catch(error => {
// this.play = false;
// console.log(JSON.stringify(error));
// });
}
pauseQuestion() {
}
async openHint(hint) {
let hintModal = await this.modalCtrl.create({
component: HintComponent,
componentProps: {
hint,
},
});
hintModal.present();
}
}
<div class="flexbox">
<div class="noWrap" *ngIf="data?.questionNumber">{{data?.questionNumber}} .</div>
<div style="flex: 1;" class="_flex-direction-column ion-padding-start">
<div *ngFor="let question of data.question;let first = first">
<div class=" _flex-box _justify-content-space-between">
<div class="wrapText">{{question}}</div>
</div>
</div>
</div>
<div *ngIf="data?.hint">
<ion-icon name="bulb" class="noWrap ion-margin-start help" (click)="openHint(data?.hint)"></ion-icon>
</div>
</div>
.flexbox {
display: flex;
align-items: baseline;
flex-wrap: nowrap;
}
.noWrap {
white-space: nowrap;
text-align: justify;
}
.wrapText {
white-space: wrap;
}
.help {
font-size: 1.875rem;
color: grey;
}
Legend
Html element with directive