小编pla*_*one的帖子

Typescript blob文件名没有链接

如何在打字稿中设置blob的文件名?对于IE,我可以轻松设置文件名,但对于Chrome,它看起来不可能.基本上我需要类似于这个解决方案但有打字稿的东西

downloadFile(data: any) {
    var blob = new Blob([data], {type: 'text/csv'});
    let fileName = 'my-test.csv';

    if (window.navigator && window.navigator.msSaveOrOpenBlob) {
        //save file for IE
        window.navigator.msSaveOrOpenBlob(blob, fileName);
    } else {
        //save for other browsers: Chrome, Firefox

        var objectUrl = URL.createObjectURL(blob);
        window.open(objectUrl);
    }
}
Run Code Online (Sandbox Code Playgroud)

从html UI/angular 2调用此函数:

<button type="button" class="btn btn-success"
(click)="downloadFile('test')">Download <br /> Download </button>
Run Code Online (Sandbox Code Playgroud)

google-chrome blob typescript angular

7
推荐指数
1
解决办法
7583
查看次数

如何使用 angular-oauth2-oidc 获取访问令牌进行 PKCE 代码身份验证?

我正在使用 angular-oauth2-oidc 进行身份验证,但我不知道如何获取访问令牌。我正在使用具有此配置的 PKCE 代码流

  authConfig: AuthConfig = {
    issuer: 'https://test.com/oauth/token',
    // requireHttps: false,
    redirectUri:'http://localhost:4200/',
    strictDiscoveryDocumentValidation: false,
    tokenEndpoint: 'https://test.com/oauth/token',
    clientId: 'test',
    // dummyClientSecret: 'test',
    scope: 'openid',
    oidc: true,
    responseType: 'code',
    showDebugInformation: true,
    requestAccessToken: true
  };
Run Code Online (Sandbox Code Playgroud)

流程是使用此代码启动的,登录后它会被重定向,但我无法获得任何令牌。

  getAutherizationCodeWithPKCE() {
    this.oauthService.configure(this.authConfig);
    this.oauthService.initCodeFlow();
    this.oauthService.loadDiscoveryDocumentAndTryLogin
}
Run Code Online (Sandbox Code Playgroud)

oauth-2.0 angular angular-oauth2-oidc pkce

5
推荐指数
1
解决办法
9791
查看次数

Angular 2 ng2-charts 甜甜圈更改段颜色

这是与链接相关的问题

我正在尝试使用圆环图创建组件并传递输入参数颜色来设置圆环图颜色段。我正在 ngOnInit() 中对图表进行初始化。颜色会更改为悬停(hoverBackgroundColor),但不会更改背景颜色。我错过了什么吗?

    import {Component, OnInit, Input} from '@angular/core';

@Component({
    selector: 'donut-medium',
    templateUrl: './donut-medium.component.html',
    styleUrls: ['./donut-medium.component.css']
})
export class DonutMediumComponent implements OnInit {

    @Input() color: any;
    @Input() percentage: number;
    @Input() text1: string;
    @Input() text2: string;
    colors: any[]=[];

    // Doughnut
    public doughnutChartLabels: string[] = [];
    //public doughnutChartData: number[] = [];
    public doughnutChartType: string ;



    public doughnutChartOptions: any;
    public doughnutChartDatasets: any[];

    // events
    public chartClicked(e: any): void {
        console.log(e);
    }

    public chartHovered(e: any): void {
        console.log(e);
    }


    ngOnInit() {
        console.log('color', …
Run Code Online (Sandbox Code Playgroud)

chart.js ng2-charts angular

4
推荐指数
1
解决办法
5356
查看次数

我应该在 Ionic 5 中使用 Ngrx 吗?

在 Ionic 5 的移动应用程序中使用 ngrx 时,我几乎没有什么顾虑:

  1. 移动设备上的性能问题。= ngrx 是状态管理,因此来自 API 的所有数据都将存储在内存中并随时可访问。这会影响一些旧设备(例如 android 4.4)吗?

  2. 太多 ngrx 样板会增加应用程序包的大小。

  3. 由于很多限制,无法使用 ngrx/data ..

  4. ngrx 是第 3 方库。它与 Ionic Angular 100% 兼容吗?

有没有人遇到过类似的问题?

ionic-framework ngrx angular

1
推荐指数
1
解决办法
3992
查看次数

打字稿:无法读取未定义的属性“toLowerCase”

我在线收到此错误:

 return filter ? value.filter(element => element.type.toLowerCase().indexOf(filter.toString().toLowerCase()) != -1) : value;
Run Code Online (Sandbox Code Playgroud)

当 element.type 为空字符串时(过滤空列)。如何解决这个问题?

typescript angular2-filtering angular

0
推荐指数
1
解决办法
2万
查看次数

如何显示模式验证消息?

我向模板添加了模式属性

<input class="form-control" type="text" id="elementName"
                                   [(ngModel)]="elementName" name="elementName"
                                   (input)="onElementNameChanged()" #name="ngModel" required pattern="[A-Za-z0-9_)*\S]*" >
Run Code Online (Sandbox Code Playgroud)

如何添加输入不正确时显示的消息?

像这样的东西不会工作:

<div [hidden]="!name.errors.pattern"
     class="alert alert-danger">
     Name must match pattern
</div>
Run Code Online (Sandbox Code Playgroud)

html angular2-forms angular2-template angular

0
推荐指数
1
解决办法
2万
查看次数