需要使用http get请求的材料自动完成示例

时间:2018-01-02 20:16:38

标签: material-design angular-material angular-material2 angular4-forms

我正在遵循材质文档中的Angular Material AutoComplete示例。

根据文档使用options []值时,它工作正常。当我从api获取数据时,我无法让它工作。 如果我不使用过滤器选项,则会显示书籍列表。只是当使用过滤器时,它有问题。

this.filterOptions抱怨

  

类型'Observable'不能分配给类型   “可观测”。类型'Book []'不能分配给类型   '串[]'。       类型'Book'不能指定为'string'类型。

为什么在使用选项[]时不抱怨。

class SenseNode
{
public:
  SenseNode() {};
  SenseNode(uint8_t aNodeId): id(aNodeId) {}
  virtual ~SenseNode() {}

  uint8_t getId() { return id; };
private:
  uint8_t id = 0;
};

class SenseStateNode : virtual public SenseNode
{
public:
  SenseStateNode(uint8_t aNodeId) : SenseNode(aNodeId) {}
  virtual ~SenseStateNode() {}

  /** Return current node state interpreted as an integer. */
  virtual int getValueAsInt();
};

class SenseObservable: public SenseStateNode
{
public:
  SenseObservable(uint8_t aNodeId);
  virtual ~SenseObservable();
  /** Notify all interested observers of the change in state by calling Observer.notification(this) */
  virtual void notifyObservers();
protected:
  virtual void registerObserver(SenseObserver *);
  virtual void unregisterObserver(SenseObserver *);
};

class SenseObserver: virtual public SenseNode
{
public:
  SenseObserver() {};
  virtual ~SenseObserver();

  /** Called by an Observable that we are observing to inform us of a change in state */
  virtual void notification(SenseObservable *observable) {
    int v = observable->getValueAsInt(); // works like a charm
    DateTime d = observable-> ????  // How should i solve this elegantly?
  };
};

0 个答案:

没有答案