代码之家  ›  专栏  ›  技术社区  ›  Theo Itzaris

如何在转换路由时启用组件的属性

  •  2
  • Theo Itzaris  · 技术社区  · 7 年前

    你好,我有一个页面标题上的搜索组件。
    当我点击放大镜时 flag true ,所以 search-box 组件显示如下:

    enter image description here

    application/controller.js 它重定向到 result-page ,就像这样:

    `actions: {
    updateQuery(query) {
      return this.transitionToRoute('search-results', {
        queryParams: {
          query
        }
      })
     }
    }
    

    搜索框 header 组件,还没有。

    当我重新定向时,你知道怎么触发吗?

    1 回复  |  直到 7 年前
        1
  •  2
  •   Ahmet Emre Kilinc    7 年前

    你能应付的 flag 你的财产 application/controller.js flag=flag 并将其绑定到搜索组件。然后,在你的 updateQuery 控制器的操作您可以设置 旗帜 假象:

    updateQuery(){
      this.set('flag', false);
      this.transitionToRoute('search-results');
    }
    

    this twiddle 对于这种用法。