I have this variable holding the data
var tooltipsJson = [{
"Language": "en-GB",
"Section": "Sales&Marketing",
"ItemName": "CalculationType",
"Texts": "Having selected the account heading select the calculation ..."
},
{
"Language": "en-GB",
"Section": "Taxes",
"ItemName": "Save",
"Texts": "The Master Tax Table has been pre populated with the current UK, ..."
}
];
and I want to use the underscore.js each
_.each(.........)
so that when I put:
console.log({{tooltipsJson.Taxes.Save}});
to display the text
The Master Tax Table has been pre populated with the current UK, ...
I want the Texts attribute to be assigned to a local variable
Please Try;
$scope.obj = {};
_.each(tooltipsJson, function( val, key ) {
$scope.obj[key] = val;
});
If you want to print all "Texts" attribute of the objects in the array you call .each() like this:
_.each(tooltipsJson, function(item){
console.log(item.Texts);
});
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.