首页 > 解决方案 > 无法以角度获取价值形式的服务类

问题描述

component.ts 文件
导入 { Component, OnInit, Input } from '@angular/core';
从'../../../../shared/history.service'导入{ HistoryService };
从“@angular/router”导入{路由器};
从'@angular/forms'导入{ NgForm };
从'../../../../shared/history.model'导入{历史};

@Component({
  selector: 'app-ins-history',
  templateUrl: './ins-history.component.html',
  styleUrls: ['./ins-history.component.css'],
  providers:[HistoryService]
})

export class InsHistoryComponent implements OnInit {

  constructor(public UserProfileService: HistoryService, private router: Router) { }


  ngOnInit() {

    this.HistoryList();
  }

  HistoryList()
  { let title = this.UserProfileService.Title;
      console.log(title);
      this.UserProfileService.getHistoryList(title).subscribe((res)=> {
      this.UserProfileService.history= res as History[];
      alert('ok');

    });
  }

}[historyservice.ts][1]

https://i.stack.imgur.com/sRRke.png

标签: angular

解决方案


推荐阅读