滚动到顶部

时间:2019-02-13 14:58:49

标签: angular mat-table

我想在matTable中创建一个用于“将滚动移到顶部”的按钮,但我没有得到。

namespace asio {
  namespace detail {

    template <typename Exception>
    void throw_exception(const asio::invalid_service_owner &service_owner) {
      std::cerr << "Something just happened: " << service_owner.what() << std::endl;
      std::terminate();
    }

    template <typename Exception>
    void throw_exception(const Exception &e) {
      std::cerr << "Something just happened: " << e.what() << std::endl;
      std::terminate();
    }
  }  // namespace detail
}  // namespace asio

namespace dbc {

  namespace detail {

    /// \brief Connection pool.
    struct pool : public std::enable_shared_from_this<pool> {
      // Make object non-copyable.
      pool(const pool &) = delete;
      auto operator=(const pool &) -> pool & = delete;

      /// \brief Constructor
      /// \param[in] config Configuration data supplied by the end user.
      explicit pool(const pool_parameters &config) noexcept;

      pool_parameters m_config;
      /// \brief Thread pool where tasks are asynchrinously executed.
      asio::thread_pool m_t_pool;
    };
  }  // namespace detail
}  // namespace dbc

但是它不起作用,nativeElement不是MatTable的元素,我该怎么办?

1 个答案:

答案 0 :(得分:1)

您已经接近解决方案,您只缺少一件事。您需要告诉ViewChild要从选择器中读取哪个令牌。在您的情况下,可以通过以ElementRef的形式传递第二个参数来成为{ read: ElementRef }

@ViewChild('table', {read: ElementRef}) table: ElementRef;
  

Here   是一个展示它的实际效果的闪电战。