[英]Ember-CLI: How do I write an initializer in coffeescript?
I've generated an application using Ember-cli. 我已经使用Ember-cli生成了一个应用程序。 I've created an initializer but I'm running into an issue.
我已经创建了一个初始化程序,但是遇到了问题。
I'm getting the error: 我收到错误消息:
Uncaught TypeError: Cannot read property 'name' of undefined
app/initializers/user-auth.coffee 应用程序/初始化/ user-auth.coffee
`import Ember from 'ember'`
`import Base from 'simple-auth/authenticators/base'`
SFDCAuthenticator = Base.extend(
# auth here
)
SFDCInit = Ember.Application.initializer(
name: 'authentication'
before: 'simple-auth'
initialize: (container, application) ->
container.register 'authenticator:custom', SFDCAuthenticator
)
`export default SFDCInit`
You need to export an object from the initializer, you don't use Ember.Application.initializer
您需要从初始化程序中导出对象,而不使用
Ember.Application.initializer
Something like this 像这样
`import Base from 'simple-auth/authenticators/base'`
SFDCAuthenticator = Base.extend(
# auth here
)
SFDCInit =
name: 'authentication'
before: 'simple-auth'
initialize: (container, application) ->
container.register 'authenticator:custom', SFDCAuthenticator
`export default SFDCInit`
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.