在Angular渲染之前获取数据(Angular 2 +)

时间:2018-11-28 20:14:18

标签: javascript angular voice

在渲染html之前,我需要执行此代码。有任何想法吗?我查看了Promises,Callbacks和Observables

  voices;

  ngOnInit() {
    if ('speechSynthesis' in window) {
      speechSynthesis.onvoiceschanged = () => {
        this.voices = window.speechSynthesis.getVoices();
      };
    }
  }

0 个答案:

没有答案