javascript - AngularJS, get scope with object-id -


is possible specific scope of object accesing through id?

i use angular ui tree navigation menu. after add subitem , save navigation mysql database, node subitem not expanded. after push, see menu expands, after saving in database , rerendering navigation menu, node not expanded.

have solution?

json-object of menu.

[   {     "id": 35,     "title": "foo",     "items": []   },   {     "id": 34,     "title": "bar",     "items": [       {         "id": 123,         "title": "foobar",         "items": []       },     ]   },   {     "id": 46,     "title": "barfoo",     "items": []   }, ] 

this structure saved following code

function setmenu(nodeid) {         $http.post("...", {             "menujson" : $scope.menu         }).success(function (data, status, headers, config) {             if (status == 200) {                 loadadminnavigation();             }         });     }; 

after saving in mysql database, structure reloaded code

function loadadminnavigation() {         $http.get("...").success(function (response) {             $scope.menu = response;         });     }; 

if add subitem, scopes new, want expand node id model. need know how can access scope via id.

example code scope of element:

var documentresult = document.getelementsbyid("someid"); angular.element(documentresult).scope(); 

official angular docs element:

https://docs.angularjs.org/api/ng/function/angular.element

scope() - retrieves scope of current element or parent. requires debug data enabled.

can read post: how access $scope variable in browser's console using angularjs?


Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -