我很难正确使用我的术语。在以下代码中:
Notes.NotesController = Ember.ArrayController.extend({
newNoteName: null,
actions: {
createNewNote: function() {
var content = this.get('content');
var newNoteName = this.get('newNoteName');
var unique = newNoteName != null && newNoteName.length > 1;
content.forEach(function(note) {
if (newNoteName === note.get('name')) {
unique = false; return;
}
});
if (unique) {
var newNote = this.store.createRecord('note');
newNote.set('id', newNoteName);
newNote.set('name', newNoteName);
newNote.save();
this.set('newNoteName', null);
} else {
alert('Note must have a unique name of at least 2 characters!');
}
}
}
});
什么是“newNoteName:”、“actions:”和“createNewNote:”?
它们是方法、属性还是钩子?有什么区别?'createNewNote' 嵌套在 'actions:' 中是否使 'actions' 完全不同?
ember“钩子”和您自己创建和命名的方法/属性以及它们的使用方式有什么区别?
谢谢。'
[更新]
“内容”从何而来?
Notes.NotesNoteController = Ember.ObjectController.extend({
actions: {
updateNote: function() {
var content = this.get('content');
console.log(content);
if (content) {
content.save();
}
}
}
});
它不是模型的属性,所以 Ember 如何知道要检索什么
this.get('content')
它带有textArea
车把助手吗?