Bugsnag& Emberjs:application.lookup不是函数

时间:2017-06-15 14:27:00

标签: javascript ember.js deprecated bugsnag

我试图在我的EmberJs(v2.12)应用程序中配置 Bugsnag

我正在关注此示例:https://gist.github.com/ToddSmithSalter/23ad9ed91a693b498709

但我在浏览器中发现错误,告知查找不是函数。

应用/初始化/ bugsnag.js

import Ember from 'ember';
import config from '../config/environment';

export default {
  name: 'bugsnag',

  initialize: function(appInstance) {

      // appInstance.lookup is not a function
      var appController = appInstance.lookup('controller:application');
  }
};

有人可以在emberjs初始化程序中访问应用程序控制器吗?

或者可能是在Emberjs应用程序上安装bugsnag的更好解决方案?

1 个答案:

答案 0 :(得分:1)

您需要创建instance-initializer而不是initializer Ember.Application - 没有lookup方法,但Ember.ApplicationInstance有。

参考:
https://guides.emberjs.com/v2.13.0/applications/applications-and-instances/ https://emberjs.com/api/classes/Ember.ApplicationInstance.html https://emberjs.com/api/classes/Ember.Application.html