[英]how to deal with the unknown id with ember-data and emberjs
App.Router.map ->
@resource "sentences", ->
@resource "sentence",
path: ":sentence_id", ->
App.Sentence = DS.Model.extend(
subject: DS.attr("string")
)
http://localhost:3000/#/sentences/5
If your server sends a 404, for such a request, Ember will raise an exception which can be handled via an errors
handler on the route. 如果您的服务器发送了404,则对于此类请求,Ember将引发异常,该异常可以通过路由上的
errors
处理程序进行处理。 From there you can display this in the UI or transitionTo
another route that can display the error. 从那里可以在UI中显示此内容,也可以
transitionTo
到可以显示错误的另一条路线。
App.PostRoute = Ember.Route.extend({
events: {
error: function(reason, transition) {
// display error or transitionTo here
}
}
});
how to use the two params 'reason', 'transition' 如何使用两个参数“原因”,“过渡”
Is it possible to show one example 可以举一个例子吗
why does it have two params here? 为什么这里有两个参数?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.