ng-packagr 打包報錯 Public property X of exported class has or is using name 'Observable' from external

oldide

import { Injectable } from '@angular/core';
import { BehaviorSubject } from 'rxjs';

@Injectable({
  providedIn: 'root'
})
export class DataService {
  private dataSource = new BehaviorSubject(Object);
  public currentData = this.dataSource.asObservable();

  constructor() {}

  changeData(data) {
    this.dataSource.next(data);
  }
}

new :紅色部分是重點 this

import { Injectable } from '@angular/core';
import { BehaviorSubject, Observable } from 'rxjs';

@Injectable({
  providedIn: 'root'
})
export class DataService {
  private dataSource = new BehaviorSubject(Object);
  public currentData: Observable<Object> = this.dataSource.asObservable();

  constructor() {}

  changeData(data) {
    this.dataSource.next(data);
  }
}

問題:可觀測屬性的問題,spa

 

當我使用的是可觀測的屬性,但找不到它。要解決這個問題,我須要簡單地添加缺乏的可觀察導入,並在當前數據變量中鍵入:而後就能夠解決了code

相關文章
相關標籤/搜索