Git
- 1 ответ
- 0 вопросов
3
Вклад в тег
var origObj = {
a: {
a_val1: {
a_val1_a: "some text"
},
a_val2: "text"
},
b: {
b_val1: {
b_val1_a: "one more",
b_val2_a: "one more2"
},
b_val2: "this is string"
}
}
var text = "one more2";
function search(obj, path) {
obj._path = path;
for (var key in obj) {
if (!obj.hasOwnProperty(key) || key === '_path') {
continue;
}
obj[key]._path = (obj._path + "." + key);
if (typeof obj[key] === "object") {
search(obj[key], obj[key]._path);
}
else if (obj[key] === text) {
console.log(text, " найден в объекте: " + obj._path + " , свойсво: " + key);
}
}
}
search(origObj, "origObj");
<body>
<div data-ui-view="content"></div>
<div data-ui-view="contacts"></div>
</body>
$stateProvider
.state('find', {
url: "/find",
views: {
'content': {
templateUrl: "/content.html",
controller: 'registerController'
}
}
})
.state('contacts ', {
url: "/contacts ",
views: {
'content': {
templateUrl: "/content.html",
controller: 'contentController'
},
'contacts': {
templateUrl: "/contacts.html",
controller: 'contactsController'
}
}
});