DEPRECATION:控制器#需求已被弃用,请改用Ember.inject.controller() [英] DEPRECATION: Controller#needs is deprecated, please use Ember.inject.controller() instead

查看:115
本文介绍了DEPRECATION:控制器#需求已被弃用,请改用Ember.inject.controller()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


DEPRECATION:控制器#的需求已被弃用,请使用Ember。 inject.controller()而不是


找不到关于如何编写新语法的文档。关于如何解决这个警告的任何建议将不胜感激。

解决方案

由于某种原因,它被标记为 docs ,为了看到它,你需要勾选私人复选框。



有两种方法可以使用它,只要传递控制器名称就可以了。

  App.PostController = Ember.Controller.extend({
posts:Ember.inject.controller()
});

当控件的名称未被传递时,ember使用属性名称来查找作为帖子:Ember.inject.controller('posts')



您只会指定控制器名称当财产和控制器有不同的名称。

  App.PostController = Ember.Controller.extend({
myPosts :Ember.inject.controller('posts')
});


Just updated Ember to v1.13.5, and received this warning:

DEPRECATION: Controller#needs is deprecated, please use Ember.inject.controller() instead

Can't find the documentation yet on how to write the new syntax. Any suggestions on how to fix this warning would be appreciated.

解决方案

For some reason it's marked as a private method in the docs, in order to see it you ll need to tick the private checkbox.

There are 2 ways to use it, with and without passing a controller name to it

App.PostController = Ember.Controller.extend({
  posts: Ember.inject.controller()
});

When the name of the controller isn't passed, ember uses the property name to look it up such as posts: Ember.inject.controller('posts').

You will only ever specify the controller name when the property and the controller have different names.

App.PostController = Ember.Controller.extend({
  myPosts: Ember.inject.controller('posts')
});

这篇关于DEPRECATION:控制器#需求已被弃用,请改用Ember.inject.controller()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆