简体   繁体   中英

How to add child row to parent record in Angularjs

var data = [{
"_id": "5814c04ca105fa8eb6e3e08a",
"name": "aa33",
"address": "bb33",
"updateby": "matt",
"Histories": [{
    "svr_id": "a1122",
    "details": "well",
    "updateby": "matt",
    "_id": "5814c5cdb41151ca54871f5d"
}],
"lastupdate": "2016-11-03T11:18:26.000Z"
}]

I am new in Angularjs. I have data in mongo database. Everything works fine in CRUD for parent level only. If I have child level "Histories" shown above , how can I add another new child row in Histories node.

Thanks

Because you've defined your objects as arrays, you must access them as such. To add a new key/value to Histories, please do this:

data[0].Histories[0].newKey = "newVal";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM