如何在 TypeScript 中打印字母表?

Urs*_*nth 3 typescript angular

我们正在尝试使用 Angular 设计一个医疗保健应用程序。对于数据过滤,我们正在创建一个如下图所示的栏:

数据过滤条图像

为了减少代码行,我们在 Typescript 中编写代码,我们正在控制台中检查它是否显示。

我们没有得到预期的输出,也没有显示错误。

任何人都可以解决这个问题吗?

listIndex(){
while (this.i <= 90) {
    this.alphabets.push(String.fromCharCode(this.i));
}
console.log(this.alphabets());}
Run Code Online (Sandbox Code Playgroud)

输出:

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Run Code Online (Sandbox Code Playgroud)

为了您的参考,我发布了完整的 TS 文件:

import {Component} from '@angular/core';
import {HttpService} from '../../service/http.service';


@Component({
    selector: 'patienthtml',
    templateUrl: 'app/component/patient/patient.html',
    providers: [HttpService]
})

export class PatientComponent{
constructor( private httpService: HttpService ) {
}
 //simple call init function on controller
i=65;
step = 0;

patientData : any;
alphabets: any = [];

public ngOnInit(): any
{
    this.getPatientData();
}
 getPatientData(){

    this.httpService.getPatients("PatientData").subscribe(
    resp => {    
        if(resp!=null){

            this.patientData=resp.response;
        }
        console.log(this.patientData);
    },
    error => {
        console.log(error);
    }
    );   
}
listIndex(){
    console.log('ReachedHere');
    let alphabets = [];
    for (let i = 65; i <= 90;i++) {
        alphabets.push(String.fromCharCode(this.i));
    }
    console.log(alphabets);

}
getCurrentStep() {
    return this.step;
}
goback(){
    this.step = this.step - 1;    }

toReport(){
    this.step = this.step + 1;    }

}
Run Code Online (Sandbox Code Playgroud)

Rit*_*itz 5

希望这可以帮助...

let alphabets = [];
for (let i = 65; i <= 90;i++) {
    alphabets.push(String.fromCharCode(i));
}
console.log(alphabets);
Run Code Online (Sandbox Code Playgroud)