角度组件导致程序失败

时间:2017-08-09 01:07:40

标签: angular

我一直在研究Angular应用程序,并且一直在跟踪/调整角度的TOH示例,但是这个特定的组件导致我的项目失败。

有没有人看到我不会导致这种失败的事情?

import 'rxjs/add/operator/switchMap';
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, ParamMap } from '@angular/router';
import { Location } from '@angular/common';

import { Purchase } from './purchase';
import { PurchaseService } from './purchases.service';

@Component({
  selector: 'purchaseDetails',
  templateUrl: './purchase-detail.component.html'
})
export class PurchaseDetailComponent implements OnInit {
  purchase: Purchase;

  constructor(
    private purchaseService: PurchaseService,
    private route: ActivatedRoute,
    private location: Location
  ) {}

  ngOnInit(): void {
    this.route.paramMap
      .switchMap((params: ParamMap) => this.purchaseService.getPurchase(+params.get('id')))
      .subscribe(purchase => this.purchase = purchase);
  }
}

应用程序在我的“正在加载...”文本

的索引页面上挂起

1 个答案:

答案 0 :(得分:0)

我在组件HTML文件中发现了这个问题。应该检查网页上的错误! :/