QML model link to JSON data -
how link json stream qml model angularjs?
in qml, have websocket object receives data server:
websocket { id: socket url: "ws://3.249.251.32:8080/jitu" ontextmessagereceived: { var jsonobject = json.parse(message) } onstatuschanged: if (socket.status == websocket.error) { console.log("error: " + socket.errorstring) } else if (socket.status == websocket.open) { console.log("socket open"); } else if (socket.status == websocket.closed) { console.log("socket closed"); } active: false }
in json have like:
{ items: [ "foo", "bar" ] }
then want display 2 tabs, on titles foo , other, unsurprisingly, titled bar.
this work great if create repeater goes through array in model , create tab each entry:
tabview { anchors.fill: parent repeater { model: listmodel { id: tabs } tab { title: caption rectangle { color: "red" } } } }
up now, looks angularjs. need update model (scope angular) data received through websocket. this, have add tabs json listmodel such:
... ontextmessagereceived: { var jsonobject = json.parse(message) tabs.append(jsonobject.itu.modalities); } ...
the problem is, each time i'll receive update json, tabs added. don't want clear listview each time, time consuming think. there smart way update model json smartly ? in angular, both javascript structure, easy merge. here, don't see easy way.
Comments
Post a Comment