AngularDart 在没有手动刷新的情况下无法通过查询参数检测状态更改。有没有办法强制组件重新加载?

AngularDart not detecting state change with query parameters without a manual refresh. Is there a way to force a component to reload?

我正在从查询参数中提取一些字段并使用它们进行 API 调用。从服务器接收到数据后应该会显示,但什么也没有发生(打印语句确认正在接收数据)。

当没有相关的查询参数时,我在 OnInit 中使用了这个模式并且它工作正常,但这次我肯定错过了更多,因为我尝试使用 OnInit 而不是 OnActivate 硬编码 url 参数并得到相同的结果,组件从不更新新数据,直到手动刷新页面。一旦设置了推荐对象,是否有办法强制组件自行刷新?

class SolutionsComponent implements OnInit, OnActivate {
  static final url_path = "http://localhost/api/solutions/";
  SolutionsComponent();

  Recommendations recommendations = null;

  @override
  void ngOnInit() {
  //Google Analytics stuff in here
  }

  Future<Recommendations> loadRecommendations(url) {
    setRecommendationsFromJson(String response) {
      return Recommendations.fromJson(json.decode(response));
    }

    return HttpRequest.getString(url).then(setRecommendationsFromJson);
  }

  @override
  void onActivate(RouterState previous, RouterState current) {
    var id = getId(current.queryParameters);
    var recommendation = getSolution(current.queryParameters);
    var url = "${url_path}${recommendation}_${id}";
    loadRecommendations(url).then((data) {
      print("${data}");
      recommendations = data;
     print("${recommendations}");
    });
  }
}

致电ChangeDetectorRef.markForCheck

class SolutionsComponent implements OnInit, OnActivate {
  final ChangeDetectorRef _cdRef:
  SolutionsComponent(this._cdRef);

  void setRecommendationsFromJson(...) {
    ...
    _cdRef.markForCheck();
  }
}