小编Has*_*hif的帖子

iframe中的PDF显示标题为"匿名"

我正在使用Angular2.我从后端API获取PDF响应作为BLOB.PDF在iframe中显示正常,但它显示标题为"匿名".有人可以指导吗?

HTML代码:

<iframe id="showPDFIframe" allowtransparency="false" title="TestPDF" width="100%" height="800" [attr.src]="dataLocalUrl" type="application/pdf"></iframe>
Run Code Online (Sandbox Code Playgroud)

pdf.component.ts

    pdfDownload: any;
    protected dataLocalUrl: SafeResourceUrl;

    ngOnInit() {
    this.requestOptions = this.createRequestOptions();
    this.requestOptions.responseType = ResponseContentType.Blob;
    this._pdfModelService.showPDF(this.requestOptions)
    .subscribe( (res) => {
      this.pdfDownload = res;
      this.dataLocalUrl = this.domSanitizer.bypassSecurityTrustResourceUrl(window.URL.createObjectURL(res));
    }, err => {
      console.log(err);
    })
   }
Run Code Online (Sandbox Code Playgroud)

pdfModelService.ts

showPDF(options?: RequestOptions): any {
    return this._http.get(this.endpoints.showPDF.uri, options)
      .map( (res) => {
        return new Blob([res], { type: 'application/pdf' })
      });
  }
Run Code Online (Sandbox Code Playgroud)

见下图'Anonymous'正在显示 在此输入图像描述

注意:后端API给出了我们在BLOB中投射的字节.

javascript pdf iframe angular

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

Angular2 ng2图表自定义?

我已经开始使用angular2了ng2-chart.我对使用angular2 ng2-chart创建的下图仍然有一些疑问,但仍想进行更多自定义:

示例图表

问题:

1)如果上面的图像中没有值,如何在两点之间画一条虚线,Nov-7的值为0(零)?

2)如何制作阴影效果,不透明度或多种颜色的组合?

3)当我将鼠标悬停在任何已定义的点上时,如果我想在鼠标悬停时更改y轴网格颜色,如何获取y轴的值.使用ng2-chart悬停功能的最佳方法是什么?

当前示例代码和配置文件:

的index.html

<div class="container">
  <div class="row">
    <div class="overview-page">
      <div class="overview-page-title">
        <h2>Overview</h2>
      </div>
      <div class="chart-view">
        <canvas baseChart
            class="chart"
            [datasets]="charts.datasets"
            [labels]="charts.labels"
            [colors]="charts.chartColors"
            [options]="charts.options"
            [legend]="false"
            [chartType]="charts.type"
            (chartHover)="chartHovered($event)">
        </canvas>
      </div>
    </div>
  </div>
</div>
Run Code Online (Sandbox Code Playgroud)

index.component.ts

import {Component, Output, EventEmitter, OnInit} from '@angular/core';
import {Router} from '@angular/router';
import {Config} from '../../../config/config';

@Component({
  templateUrl: 'index.html',
  styleUrls: ['../../../../common/stylesheets/pages/index.scss']
})

export class IndexComponent implements OnInit {

  protected charts: any;

  ngOnInit() {
    this.charts = (<any>Config.get('test')).charts;
    console.log(this.charts);
  }

  chartHovered(e:any):void {
    console.log(e);
  }
} …
Run Code Online (Sandbox Code Playgroud)

javascript charts chart.js ng2-charts angular

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

在 SVG 线性渐变停止偏移中绑定 Angular2 值?

我想在线性渐变停止偏移中使用绑定 angular2 值,但它给了我错误。有人能告诉我如何在线性渐变的停止偏移量中绑定 angular2 值,如下所示?

test.component.ts

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


@Component({
selector: 'test-comp',
templateUrl: 'test-component.html',
encapsulation: ViewEncapsulation.None
})

export class TestComponent implements OnInit {

@Input() name: string;
@Input() flexScore: number;

protected goodScore: number;
protected dangerScore: number;
protected isComplete: boolean = false;

 ngOnInit() {
  this.goodScore = this.flexScore;
  this.dangerScore = 100 - this.goodScore;
  console.log(this.goodScore + ' ' + this.dangerScore);
  this.isComplete = true;
 }
}
Run Code Online (Sandbox Code Playgroud)

测试组件.html

<div class="individual-athlete-risk">
  <span id="name">{{name}}</span>
  <span id="score">{{flexScore}}</span>
</div>
<svg width="200" height="10" xmlns="http://www.w3.org/2000/svg">
  <defs>
      <linearGradient …
Run Code Online (Sandbox Code Playgroud)

javascript svg angular

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

Angular ng build --target = production给出错误

我使用Angular-CLI创建了一个新的Angular项目.

我使用的版本是:

Angular-Cli:1.0.2

角度:4.0.0.

我已经在其中添加了很多代码但是现在,当我使用下面的命令构建我的项目时,我得到了大量的错误

ng build --target=production --env=staging

错误:

/src/app/views/signup/signup.component.html(21,86):属性'email'受到保护,只能在类'SignUpComponent'及其子类中访问.

/src/app/views/signup/signup.component.html(26,80):属性'password'受到保护,只能在类'SignUpComponent'及其子类中访问.

在这方面有人可以帮助我,我该如何删除这些错误?当我--target=production在过去省略BUT 时构建成功我遇到了一个问题,即没有指定目标浏览器缓存旧的部署版本,用户必须删除浏览器缓存以实现最新的更改/部署.

production build angular-cli angular

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