router.js有無法加載形式創建模型的新實例
Router.map(function() {
this.route('concepts');
this.route('create-concept', { path: '/concepts/new' });
this.route('concept', { path: '/concepts/:id' });
});
控制器/創建-concept.js有
import Ember from 'ember';
export default Ember.Controller.extend({
actions: {
create: function() {
var concept = this.store.createRecord('concept', {
description: this.get('description').trim()
});
this.set('description', '');
concept.save();
}
}
});
模板/創建概念.js has
{{textarea value="description"}}
{{action 'create'}}
個路由/創建-concept.js只是默認
import Ember from 'ember';
export default Ember.Route.extend({
});
當我去到我的瀏覽器的URL /concepts/new
,但是,我只是得到我的瀏覽器中的錯誤
Uncaught TypeError: Cannot read property 'getAttribute' of undefined
。我不知道這個通用錯誤的原因是什麼,關於這個文檔似乎很稀少......
編輯 - 當我訪問/概念,並點擊鏈接到/概念/新的,它顯示
Preparing to transition from 'concepts' to ' create-concept'
Transitioned into 'create-concept'
所以它會出現,它並找到正確的路線
因爲它很難複製並粘貼此出於某種原因,這裏的堆棧跟蹤的部分截圖:
EDIT 2 - Minimal code demonstrating problem
你將包括堆棧跟蹤,在我添加了如下答案的信息折騰只是一個部分,並沒有回答你的第一個問題。 – Kingpin2k
另外,我認爲你已經有了一個潛在的衝突路線,儘管Ember可能會很好,但我並不積極,它總能看到'/ concepts/new'爲id爲'new'的'概念'路線' – Kingpin2k
我可能會簡化,儘可能多地發表評論,如果你想在emberjs.jsbin.com上嘗試和複製,這也會有所幫助。 – Kingpin2k