小编bai*_*rio的帖子

Angular 2 - 无法实例化循环依赖

我创建自定义XHRBackend类以全局捕获401错误.在AuthService中,我有两个使用http-login和refreshToken的方法.所以我有这样的依赖链:Http - > customXHRBackend - > AuthService - > Http.我怎样才能解决这个问题?

export class CustomXHRBackend extends XHRBackend {
  constructor(browserXHR: BrowserXhr,
              baseResponseOptions: ResponseOptions,
              xsrfStrategy: XSRFStrategy,
              private router: Router,
              private authService: AuthService) {
    super(browserXHR, baseResponseOptions, xsrfStrategy);
  }

  createConnection(request: Request): XHRConnection {
    let connection: XHRConnection = super.createConnection(request);
    connection.response = connection.response
      .catch(this.handleError.bind(this));

    return connection;
  }

  handleError(error: Response | any) {
    console.log('ERROR',error['status']);
    if(error['status'] === 401) {
      this.authService.logout();
      this.router.navigate(['/']);
    }

    return Observable.throw(error);
  }
}
Run Code Online (Sandbox Code Playgroud)

AuthService.ts

@Injectable()
export class AuthService {
  private loggedIn: boolean = false;

  constructor(private http: Http) …
Run Code Online (Sandbox Code Playgroud)

javascript dependency-injection http typescript angular

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

PHPExcel - 更改所有文档的字体

我想将excel转换为pdf.在转换过程中我需要更改字体.我发现设置单个单元格的字体.是否可以为所有文档设置字体?

$phpExcel = new PHPExcel();

$styleArray = array(
    'font'  => array(
        'bold'  => true,
        'color' => array('rgb' => 'FF0000'),
        'size'  => 15,
        'name'  => 'Verdana'
    ));

$phpExcel->getActiveSheet()->getCell('A1')->setValue('Some text');
$phpExcel->getActiveSheet()->getStyle('A1')->applyFromArray($styleArray);
Run Code Online (Sandbox Code Playgroud)

php pdf fonts phpexcel

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