编程语言
首页 > 编程语言> > javascript – Ember.js RC1’模型’挂钩路线未调用

javascript – Ember.js RC1’模型’挂钩路线未调用

作者:互联网

似乎模型钩子不像RC1所记录的那样工作.使用linkTo时不会调用模型钩子,而不是通过编辑浏览器中的URL直接访问项目.

鉴于此示例应用程序:http://jsfiddle.net/wmarbut/QqDjY/

当直接访问’/#/ edit-item / 3’时,会调用模型钩子,但是当使用linkTo调用将用户引导到同一页面时,不会调用模型钩子.

鉴于http://emberjs.com/guides/routing/specifying-a-routes-model/的文档,我找不到任何解释这个的东西.这是一个错误还是我做错了?

编辑
我没有使用Ember Data也没有计划.

解决方法:

It appears the model hook is not working as documented for RC1. The model hook is not being called when a linkTo is used instead of visiting the item directly by editing the url in the browser.

这是它应该工作的确切方式.这是因为模型是通过linkTo给出的.当你写{{linkTo posts post}}时,模型是第三个参数.无需调用模型钩子.模型挂钩仅在通过URL进入状态时执行,因为它必须查找模型.

在你的小提琴中你有{{#linkTo editItem item.id}} {{item.name}} {{/ linkTo}}.你不需要这样做.您应该{{#linkTo editItem item}} {{item.name}} {{/ linkTo}}.然而,这并不能解决“问题”.它会自动进行查找.

标签:javascript,ember-js,ember-router
来源: https://codeday.me/bug/20190529/1179376.html