Javascript 未在特定属性上建立双向数据绑定
我试图建立一个双向数据绑定,以便在前端编辑模式属性。我的标题编辑和选择编辑工作完美,但我似乎无法在scene.content中获取要绑定的内容 这是我正在使用的编辑表单:Javascript 未在特定属性上建立双向数据绑定,javascript,angularjs,Javascript,Angularjs,我试图建立一个双向数据绑定,以便在前端编辑模式属性。我的标题编辑和选择编辑工作完美,但我似乎无法在scene.content中获取要绑定的内容 这是我正在使用的编辑表单: <form name="sceneForm{{scene._id}}" data-ng-submit="update(scene)" data-ng-if="scene.editing"> <h5>Title</h5> <input type="text" id="scene
<form name="sceneForm{{scene._id}}" data-ng-submit="update(scene)" data-ng-if="scene.editing">
<h5>Title</h5>
<input type="text" id="sceneForm{{scene._id}}" required data-ng-model="scene.title"></input>
<br>
<h5>Edit Content</h5>
<li data-ng-repeat="content in scene.content">
<input type="text" id="sceneForm{{scene._id}}" data-ng-model="content"></input>
</li>
<br>
<h5>Edit Choices</h5>
<li data-ng-repeat="choice in scene.choices">
<input type="text" id="sceneForm{{scene._id}}" data-ng-model="choice.sceneId"></input>
<input type="text" id="sceneForm{{scene._id}}" data-ng-model="choice.displayText"></input>
</li>
<!-- OK/CANCEL -->
<button type="submit">OK</button>
<button ng-click="reset(scene)">Cancel</button>
</form>
我对AngularJS非常陌生,所以任何关于为什么会发生这种情况的想法都是非常感谢的
场景中有什么内容。content
?场景。content
包含一个字符串数组。它基本上是用来编辑基于文本的游戏的部分。内容包含每一行。如果将字符串实例数组绑定为ng模型,则会出现范围问题。您不能在ng-repeat中使用ng模型。感谢您的回复。BinarieMet,为什么它适用于我的选择数组?
var mongoose = require('mongoose');
var sceneSchema = new mongoose.Schema({
title: String,
content: [String],
choices: [{
sceneId: String,
displayText: String
}]
});
module.exports = exports = mongoose.model("Scene", sceneSchema);