0
我在做一個Express Mongo API,並由Angular應用程序使用。如何可以從Angular向Express + Mongodb API發佈itens列表
我的問題是關於張貼itens列表。
這是我蒙戈方案:
var TestSchema = new mongoose.Schema({
title: String,
colors: {
name: String,
hex: Number
}
});
如何一個我可以張貼數組的顏色?
我想就這樣說:
<input type="text" ng-model="test.colors[0].name">
<input type="text" ng-model="test.colors[1].name">
<input type="text" ng-model="test.colors[2].name">
但是,被張貼類似的東西並不起作用:
{"1":{"colors":"red"},"2":{"colors":"blue"},"3":{"colors":"green"}}
謝謝你們。
但仍然沒有工作。我認爲問題出在以下格式的數據上: {「1」:{「colors」:「red」},「2」:{「colors」:「blue」},「3」:{「colors」 :「green」}} –
您是否嘗試過使用push方法將值插入到數組中? –