i have object value in JSON, within which it contains array.i am trying to group the subdocument but does not work. my plunk
The below is my controller code.
Controller
app.controller('MainCtrl', function($scope) {
$scope.list = {
"_id": "56c4758af801160e00d176e0",
"orderfood": [
{
"_id": "569d84f04834c10e003dff36",
"qty": "1",
"confirm": "placed",
"price": 125,
"name": "Paneer Tikka"
},
{
"_id": "569d869fff1fe20e00f8ba9b",
"qty": "1",
"confirm": "placed",
"price": 85,
"name": "Falooda"
},
{
"_id": "569d869fff1fe20e00f8ba9b",
"qty": "1",
"confirm": "placed",
"price": 85,
"name": "Falooda"
}
],
"title": "Status",
"created": "2016-02-17T13:28:42.226Z"
}
});
The below is my HTML code
HTML
<p ng-repeat="(key,value) in list.orderfood | groupBy:'name'">
{{key}}
</p>
my plunk
Dont know what you want your ouput to be but you need to do this with a custom function:
<div ng-app ng-controller="Main">
<div ng-repeat="list in itemsToFilter() | filter:filterNames">
<b>{{list.name}}</b>
<li ng-repeat="item in itemsToFilter() | filter: {name: list.name}">NAME: {{item.name}}- PRICE: {{item.price}}, etc...</li>
</div>
</div>
Then in your controller:
function Main($scope) {
$scope.list = {
"_id": "56c4758af801160e00d176e0",
"orderfood": [
{
"_id": "569d84f04834c10e003dff36",
"qty": "1",
"confirm": "placed",
"price": 125,
"name": "Paneer Tikka"
},
{
"_id": "569d869fff1fe20e00f8ba9b",
"qty": "1",
"confirm": "placed",
"price": 85,
"name": "Falooda"
},
{
"_id": "569d869fff1fe20e00f8ba9b",
"qty": "1",
"confirm": "placed",
"price": 85,
"name": "Falooda"
}
],
"title": "Status",
"created": "2016-02-17T13:28:42.226Z"
}
var indexedTeams = [];
$scope.itemsToFilter = function() {
indexedTeams = [];
return $scope.list.orderfood;
}
$scope.filterNames = function(item) {
var nameIsNew = indexedTeams.indexOf(item.name) == -1;
if (nameIsNew) {
indexedTeams.push(item.name);
}
return nameIsNew;
}
}
here is a link...js-fiddle exmple: http://jsfiddle.net/L6cQN/305/
Related
I have angular 8 frontends and node js is a backend
I fetched multiple table results in a single function with sequelize package.
below I mention the result JSON from the backend...
{
"filtergroups": [
{
"id": 1,
"name": "Ram",
"subcatId": "1",
"childcatId": 1,
"createdAt": "2019-11-13T00:00:00.000Z",
"updatedAt": "2019-11-13T00:00:00.000Z",
"filters": [
{
"id": 1,
"name": "2 GB",
"filterGroupId": "1",
"productId": "1",
"createdAt": "2019-11-19T00:00:00.000Z",
"updatedAt": "2019-11-27T00:00:00.000Z"
}
]
},
{
"id": 2,
"name": "Internal Storage",
"subcatId": "1",
"childcatId": 1,
"createdAt": "2019-11-05T00:00:00.000Z",
"updatedAt": "2019-11-24T00:00:00.000Z",
"filters": [
{
"id": 2,
"name": "8 GB",
"filterGroupId": "2",
"productId": "1",
"createdAt": "2019-11-20T00:00:00.000Z",
"updatedAt": "2019-11-20T00:00:00.000Z"
}
]
}
],
"products": [
{
"id": 1,
"name": "A7",
"childcatId": "1",
"subcatId": "1",
"price": 18000,
"mrp": 21000,
"discription": "sfhshsfhsf",
"image": "http://bestjquery.com/tutorial/product-grid/demo3/images/img-7.jpeg",
"createdAt": "2019-11-13T00:00:00.000Z",
"updatedAt": "2019-11-14T02:00:00.000Z"
},
{
"id": 2,
"name": "A8",
"childcatId": "1",
"subcatId": "1",
"price": 22000,
"mrp": 25000,
"discription": "7578",
"image": "http://bestjquery.com/tutorial/product-grid/demo3/images/img-8.jpeg",
"createdAt": "2019-11-20T00:00:00.000Z",
"updatedAt": "2019-11-21T00:00:00.000Z"
},
{
"id": 3,
"name": "Woodland",
"childcatId": "2",
"subcatId": "1",
"price": 2500,
"mrp": 2800,
"discription": "7575",
"image": "http://bestjquery.com/tutorial/product-grid/demo3/images/img-7.jpeg",
"createdAt": "2019-11-20T00:00:00.000Z",
"updatedAt": "2019-11-13T00:00:00.000Z"
}
]
}
This JSON I am getting an error in display section like
CategoryComponent.html:53 ERROR Error: Error trying to diff '[object
Object]'. Only arrays and iterables are allowed
service.ts
getAllProduct(): Observable<Filter_group[]>{
let params_url = new HttpParams().set('fil_outlet',this.name);
console.log('new my ss--',this.name);
return this.http.get<Filter_group[]>("http://localhost:4500/mobile_store");
};
my component.ts
this.route.queryParams.subscribe(params => {
this.subcat = params ['=='];
this.childcat = params ['fil_outlet'];
if (this.subcat){
this.categoryService.getAllProduct().subscribe((filter_groups: Filter_group[]) => {
this.filter_groups = filter_groups;
console.log('new Query Params:', filter_groups);
});
}
});
Error its
component.html
<mat-accordion multi="true" *ngFor="let filter_group of filter_groups">
<mat-expansion-panel>
<mat-expansion-panel-header >
{{filter_group.name}}
</mat-expansion-panel-header>
<p >name</p>
</mat-expansion-panel>
</mat-accordion> <!-- filter-group .// -->
<div class="col-md-3 col-sm-6" *ngFor="let product of products">
<div class="product-grid2">
<div class="product-image2">
<a routerLink="/categories">
<img class="pic-1" src="{{product.image}}">
<img class="pic-2" src="{{product.image}}">
</a>
<ul class="social">
<li><a routerLink="/products" data-tip="Quick View"><i class="fa fa-eye"></i></a></li>
<li><i class="fa fa-shopping-bag"></i></li>
</ul>
<span class="product-discount-label">40%</span>
<a class="add-to-cart" href="">Add to cart</a>
</div>
<div class="product-content">
<h3 class="title"><a routerLink="/categories">{{product.name}}</a></h3>
<div class="price">
{{product.price}}
<span>{{product.mrp}}</span>
</div>
You are taking up the full object which has both filter_groups and products and trying to loop it. Angular loops through arrays not objects.
You need to change your code in your subscription
this.categoryService.getAllProduct().subscribe((data: Filter_group) => {
this.filter_groups = data.filtergroups;
this.products = data.products;
console.log('filter group:', filter_groups );
console.log('products:', products);
});
I need to use angularjs datatables for showing JSON data gets from API, but my JSON have child object, and I can't get this data to table.
here is my json
{
"1009": {
"id": 1009,
"serial_number": "1009-U",
"campaigns": {
"52": {
"id": 52,
"name": "testSLOV"
},
"47": {
"id": 47,
"name": "IMA PODJELE"
},
"44": {
"id": 44,
"name": "TEST DUPLO"
},
"30": {
"id": 30,
"name": "ag3"
},
"26": {
"id": 26,
"name": "fdgdfsg"
}
}
},
"1051": {
"id": 1051,
"serial_number": "1051-U",
"campaigns": {
"52": {
"id": 52,
"name": "testSLOV"
},
"43": {
"id": 43,
"name": "test weather"
},
"39": {
"id": 39,
"name": "default2"
},
"37": {
"id": 37,
"name": "ag5"
}
}
},
"1500": {
"id": 1500,
"serial_number": "1500-U",
"campaigns": {
"51": {
"id": 51,
"name": "ag10"
}
}
}
}
Here is my ctrl
var vm = this;
vm.dtOptions = DTOptionsBuilder.newOptions()
.withOption('ajax', {
url: 'url',
type: 'GET'
})
.withDataProp('data')
.withOption('processing', true)
.withOption('responsive', true)
.withPaginationType('full_numbers')
vm.dtColumns = [
DTColumnBuilder.newColumn('id').withTitle('Id'),
DTColumnBuilder.newColumn('type').withTitle($translate('TYPE')),
DTColumnBuilder.newColumn('city').withTitle($translate('CITY')),
]
I try add this in ajax,
dataSrc: function ( d ) {
angular.forEach(d, function(k, v){
console.log(k);
return k;
})
},
In console i get data, but don't know how to get data from child to table in view.
Here is htm
<table datatable="" dt-options="showCase.dtOptions" dt-columns="showCase.dtColumns" class="row-border hover" width="100%"></table>
I also try in newColumn add data.id but nothing happened.
DTColumnBuilder.newColumn('data.id').withTitle('Id'),
I get error in console
jquery.dataTables.min.js:48 Uncaught TypeError: Cannot read property 'length' of undefined
My CakePHP application generates a JSON output of all my categories as shown below:
{
"categories": [
{
"Category": {
"id": "7",
"name": "Elektronics"
}
},
{
"Category": {
"id": "8",
"name": "Gym"
}
},
{
"Category": {
"id": "4",
"name": "Nightlife"
}
},
{
"Category": {
"id": "6",
"name": "Shopping "
}
},
{
"Category": {
"id": "2",
"name": "Sport"
}
}
]
}
How can I use this data with the ngTagsInput plugin? I tried it like this but it always shows an error. It seems like it cannot handle multiple objects.
<label class="item item-input item-stacked-label">
<span class="input-label">Categories</span>
<tags-input ng-model="tags" display-property="Category.name" placeholder="New Category">
<auto-complete source="loadTags($query)"></auto-complete>
</tags-input>
</label>
Error:
Error: [ngRepeat:dupes] Duplicates in a repeater are not allowed. Use 'track by' expression to specify unique keys. Repeater: tag in tagList.items track by track(tag), Duplicate key: undefined, Duplicate value: {"Category":{"id":"7","name":"Electronics"}}
http://errors.angularjs.org/1.4.3/ngRepeat/dupes?p0=tag%20in%20tagList.item…2%3A%7B%22id%22%3A%225%22%2C%22name%22%3A%22Essen%20und%20Trinken%22%7D%7D
at ionic.bundle.js:8900
at ngRepeatAction (ionic.bundle.js:35974)
at Object.$watchCollectionAction [as fn] (ionic.bundle.js:24382)
at Scope.$digest (ionic.bundle.js:24515)
at Scope.$apply (ionic.bundle.js:24783)
at done (ionic.bundle.js:19196)
at completeRequest (ionic.bundle.js:19368)
at XMLHttpRequest.requestLoaded (ionic.bundle.js:19309)
UPDATE
You could create a function that converts your object in something that tags-input can understand.
var object = {
"categories": [
{
"Category": {
"id": "7",
"name": "Elektronics"
}
},
{
"Category": {
"id": "8",
"name": "Gym"
}
},
{
"Category": {
"id": "4",
"name": "Nightlife"
}
},
{
"Category": {
"id": "6",
"name": "Shopping "
}
},
{
"Category": {
"id": "2",
"name": "Sport"
}
}
]
};
var categories = [];
for(var i = 0; i < object.categories.length; i++){
var category = object.categories[i].Category;
var categoryToPush = {
id: category.id,
name: category.name
};
categories.push(categoryToPush);
}
categories will contain:
[{
"id": "7",
"name": "Elektronics"
}, {
"id": "8",
"name": "Gym"
}, {
"id": "4",
"name": "Nightlife"
}, {
"id": "6",
"name": "Shopping "
}, {
"id": "2",
"name": "Sport"
}]
So then you can use it in the directive writing:
<tags-input ng-model="tags" display-property="name">
<auto-complete source="loadTags($query)"></auto-complete>
</tags-input>
OLD ANSWER
Add a key-property value:
<tags-input ng-model="tags" display-property="Category.name" key-property="Category.id" placeholder="New Category">
<auto-complete source="loadTags($query)"></auto-complete>
</tags-input>
Similar issue.
So I made a webshop with firebase, and I want each product to have its own review section, and to keep it optimized I have to keep my data as flat as possible.
Consider this database structure
Lets say, after I repeat my 7 products. I want to repeat all their corresponding reviews in them, I'm new to angular & really can't figure it out.
Check out this jsfiddle which is an example of my data & lays down what I want to achieve.
// the main (app) module
var myApp = angular.module("myApp", []);
// add a controller
myApp.controller("showProducts", function($scope) {
//Products
$scope.products = [{
"brand": "Apple",
"id": 0,
"img": "img/macbook.png",
"model": 2015,
"name": "Macbook 13'",
"operatingSystem": "OS X",
"price": "1900"
}, {
"brand": "Google",
"id": 1,
"img": "img/chromebook.png",
"model": "Pixel 2",
"name": "Chromebook",
"operatingSystem": "Chrome OS",
"price": "1700"
}, {
"brand": "Dell",
"id": 2,
"img": "img/dellxps13.png",
"model": "XPS13",
"name": "Dell XP13",
"operatingSystem": "Win 10",
"price": "1500"
}, {
"brand": "Lenovo",
"id": 3,
"img": "img/lenovo.png",
"model": "A2",
"name": "Lenovo A2",
"operatingSystem": "Win 7",
"price": "999"
}, {
"brand": "Sony",
"id": 4,
"img": "img/vaio.png",
"model": "VAIO",
"name": "Sony vaio",
"operatingSystem": "Win 8.0",
"price": "1200"
}, {
"brand": "Acer",
"id": 5,
"img": "img/acer.png",
"model": "a7",
"name": "Acer A7",
"operatingSystem": "Win 8.1",
"price": "1199"
}, {
"brand": "AW",
"id": 6,
"img": "http://gearnuke.com/wp-content/uploads/2015/07/alienware-1-1.jpg",
"model": "5A",
"name": "Alienware",
"operatingSystem": "Windows 10",
"price": "5000"
}];
//Reviews
$scope.reviews = [{
"-K1bfGsnWOclf1R85Uec": {
"comment": "This laptop is great",
"rating": "5",
"user": "Maryam"
}
}, {
"-K1bg0wHIUQ9qbxspLmg": {
"comment": "This laptop is working good so far!",
"rating": "4",
"user": "spongbob"
},
"-K1bzqAQpr1br6h04bSH": {
"comment": "some comment",
"rating": "10",
"user": "test"
}
}, {
"-K1bfvS9MYGE82nTx67r": {
"comment": "This laptop is meh",
"rating": "3",
"user": "superman"
}
}, {
"-K1bgSTfbjQ-LRDScH-3": {
"comment": "daym son",
"rating": "10",
"user": "Omar"
}
}, {
"-K1bgljvaeY94E_aPQvY": {
"comment": "commenthere",
"rating": "10",
"user": "pewdiepie"
}
}, {
"-K1bgmXWai9PDake2Wh1": {
"comment": "commenthere",
"rating": "10",
"user": "tiesto"
}
}, {
"-K1bgnMlsp_Dl5ooBl2G": {
"comment": "commenthere",
"rating": "10",
"user": "ex-gf"
},
"-K1gxHCtPdEniOGNFcWi": {
"comment": "idk",
"rating": 3,
"user": "idk"
}
}];
});
.card {
margin: 1% 1% 1% 1%;
padding: 1% 1% 1% 1%;
width: 250px;
height: 150px;
overflow-y: auto;
border: 1px solid black;
}
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<body ng-app="myApp" ng-controller="showProducts">
<div class="card" ng-repeat="product in products">
<h5>{{ product.name }}</h5>
</div>
<div ng-repeat="review in reviews">
<div ng-repeat="(key, data) in review">User:{{ data.user }} | Comment:{{ data.comment }} | Rating:{{ data.rating }}</div>
</div>
</body>
At the bottom of my results, you will see all the comments. I have tried many things to get them in the right places without much success.
You can use $index to grab the correct list of reviews per product. You'll only need two ng-repeat.
// the main (app) module
var myApp = angular.module("myApp", []);
// add a controller
myApp.controller("showProducts", function($scope) {
//Products
$scope.products = [{
"brand": "Apple",
"id": 0,
"img": "img/macbook.png",
"model": 2015,
"name": "Macbook 13'",
"operatingSystem": "OS X",
"price": "1900"
}, {
"brand": "Google",
"id": 1,
"img": "img/chromebook.png",
"model": "Pixel 2",
"name": "Chromebook",
"operatingSystem": "Chrome OS",
"price": "1700"
}, {
"brand": "Dell",
"id": 2,
"img": "img/dellxps13.png",
"model": "XPS13",
"name": "Dell XP13",
"operatingSystem": "Win 10",
"price": "1500"
}, {
"brand": "Lenovo",
"id": 3,
"img": "img/lenovo.png",
"model": "A2",
"name": "Lenovo A2",
"operatingSystem": "Win 7",
"price": "999"
}, {
"brand": "Sony",
"id": 4,
"img": "img/vaio.png",
"model": "VAIO",
"name": "Sony vaio",
"operatingSystem": "Win 8.0",
"price": "1200"
}, {
"brand": "Acer",
"id": 5,
"img": "img/acer.png",
"model": "a7",
"name": "Acer A7",
"operatingSystem": "Win 8.1",
"price": "1199"
}, {
"brand": "AW",
"id": 6,
"img": "http://gearnuke.com/wp-content/uploads/2015/07/alienware-1-1.jpg",
"model": "5A",
"name": "Alienware",
"operatingSystem": "Windows 10",
"price": "5000"
}];
//Reviews
$scope.reviews = [{
"-K1bfGsnWOclf1R85Uec": {
"comment": "This laptop is great",
"rating": "5",
"user": "Maryam"
}
}, {
"-K1bg0wHIUQ9qbxspLmg": {
"comment": "This laptop is working good so far!",
"rating": "4",
"user": "spongbob"
},
"-K1bzqAQpr1br6h04bSH": {
"comment": "some comment",
"rating": "10",
"user": "test"
}
}, {
"-K1bfvS9MYGE82nTx67r": {
"comment": "This laptop is meh",
"rating": "3",
"user": "superman"
}
}, {
"-K1bgSTfbjQ-LRDScH-3": {
"comment": "daym son",
"rating": "10",
"user": "Omar"
}
}, {
"-K1bgljvaeY94E_aPQvY": {
"comment": "commenthere",
"rating": "10",
"user": "pewdiepie"
}
}, {
"-K1bgmXWai9PDake2Wh1": {
"comment": "commenthere",
"rating": "10",
"user": "tiesto"
}
}, {
"-K1bgnMlsp_Dl5ooBl2G": {
"comment": "commenthere",
"rating": "10",
"user": "ex-gf"
},
"-K1gxHCtPdEniOGNFcWi": {
"comment": "idk",
"rating": 3,
"user": "idk"
}
}];
});
.card {
margin: 1% 1% 1% 1%;
padding: 1% 1% 1% 1%;
width: 250px;
height: 150px;
overflow-y: auto;
border: 1px solid black;
}
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<body ng-app="myApp" ng-controller="showProducts">
<div class="card" ng-repeat="product in products">
<h5>{{ product.name }}</h5>
<div ng-repeat="(key, data) in reviews[$index]">User:{{ data.user }} | Comment:{{ data.comment }} | Rating:{{ data.rating }}</div>
</div>
</body>
I want to repeat all their corresponding reviews
There must be a relationship between your products and their reviews. So try to add product id to the reviews for mapping.
Once you have a mapping between product and their respective reviews you can for something like below with filter to achieve your functionality.
<div ng-repeat="product in products">
<div class="card"><h5>{{ product.name }}</h5></div>
<div ng-repeat="review in reviews | filter:{productId: product.id}"">
<div ng-repeat="(key, data) in review">User:{{ data.user }} | Comment:{{ data.comment }} | Rating:{{ data.rating }}</div>
</div>
</div>
I am working on an angular app . here i need to show data in date order for user timeline
JS:
$scope.comments = [{"_id":"535e912cc6b93c7b30479454",
"created_at":"2014-04-28 23:04:36",
"post_id":"535e912cc6b93c7b30479453",
"type":"story",
"story":"[{"_id":"535e912cc6b93c7b30479454",
"title":"test story",
"content":"this is my story...",
"created_at":2014-04-30 22:04:36"}]",
"article":"[]"
},
{"_id":"535e912cc6b93c7b30479454",
"created_at":"2014-04-25 23:04:36",
"post_id":"535e912cc6b93c7b30479453",
"type":"article"
"article":"[{"_id":"535e912cc6b93c7b30479454",
"title":"test article",
"content":"this is my article...",
"created_at":2014-04-30 22:04:36"}]",
"story":"[]"
},----
//so on
]
View:
<div ng-repeat = "data in comments">
<div class="time">
<span>{{data.created_at | DateFiltertoIso | date:'MMM-dd-yy'}}
<div>
<div ng-switch-on="data.type">
<div ng-switch-when="story">
//switch layout adn get further story data by post_id
</div>
</div>
<div ng-switch-on="data.type">
<div ng-switch-when="article">
//switch layout adn get further article data by post_id
</div>
</div>
</div>
Expected Output is like
Apr-04-14
post1
post2
/all post for that date
Apr-01-14
post5
post6
//so on
I am getting
Apr-04-2014
post1
Apr-04-2014
post2
Apr-04-2014
post3
I am newbie to angular. Any Help would be helpfull
Try this
Working Demo
Html
<div ng-controller="MyCtrl">
<div ng-repeat="data in flattenedResults">
<div class="time"> <span>
<b>{{data.created_at | badDateToISO | date:'MMM-d-yy'}} </b></span>
<div>
<u ng-show="data.story.length>0">Stories</u>
<div ng-repeat="story in data.story">
{{story.title}}{{story.created_at}}
</div>
<u ng-show="data.article.length>0">Articles</u>
<div ng-repeat="article in data.article">
{{article.title}}
</div>
Script
var myApp = angular.module('myApp', []);
myApp.filter('badDateToISO', function () {
return function (badTime) {
var goodTime = badTime.replace(/(.+) (.+)/, "$1T$2Z");
return goodTime;
};
});
myApp.controller('MyCtrl', function ($scope) {
$scope.flattenedResults = [];
$scope.comments = [{
"_id": "535e912cc6b93c7b30479454",
"created_at": "2014-04-28 23:04:36",
"post_id": "535e912cc6b93c7b30479453",
"type": "story",
"story": [{
"_id": "535e912cc6b93c7b30479454",
"title": "test story 1",
"content": "this is my story... 2",
"created_at": "2014-04-30 22:04:36"
}],
"article": "[]"
}, {
"_id": "535e912cc6b93c7b30479454",
"created_at": "2014-04-28 23:04:36",
"post_id": "535e912cc6b93c7b30479453",
"type": "article",
"article": [{
"_id": "535e912cc6b93c7b30479454",
"title": "test article 33",
"content": "this is my article... 33",
"created_at": "2014-04-30 22:04:36"
}],
"story": "[]"
}, {
"_id": "535e912cc6b93c7b30479454",
"created_at": "2014-04-25 23:04:36",
"post_id": "535e912cc6b93c7b30479453",
"type": "article",
"article": [{
"_id": "535e912cc6b93c7b30479454",
"title": "test article 1",
"content": "this is my article... 1",
"created_at": "2014-04-30 22:04:36"
}],
"story": "[]"
}, {
"_id": "535e912cc6b93c7b30479454",
"created_at": "2014-04-28 23:04:36",
"post_id": "535e912cc6b93c7b30479453",
"type": "story",
"story": [{
"_id": "535e912cc6b93c7b30479454",
"title": "test story 2",
"content": "this is my story... 2",
"created_at": "2014-04-30 22:04:36"
}],
"article": "[]"
}, {
"_id": "535e912cc6b93c7b30479454",
"created_at": "2014-04-25 23:04:36",
"post_id": "535e912cc6b93c7b30479453",
"type": "article",
"article": [{
"_id": "535e912cc6b93c7b30479454",
"title": "test article 2",
"content": "this is my article... 2",
"created_at": "2014-04-30 22:04:36"
}],
"story": "[]"
}];
$scope.jsonFlatten = function () {
$scope.dates = [];
$scope.comments.reduce(function (result, item) {
$scope.dates.push(item.created_at);
}, 0);
$scope.dates = _.uniq($scope.dates);
angular.forEach($scope.dates, function (dateValue, dateKey) {
var obj = {};
obj.created_at = dateValue;
var articleValues = [];
var storyValues = [];
angular.forEach($scope.comments, function (value, key) {
if (dateValue === value.created_at) {
obj._id = value._id;
obj.post_id = value.post_id;
if (value.type === 'story') {
angular.forEach(value.story, function (storyValue, storyKey) {
storyValues.push(storyValue)
});
} else if (value.type === 'article') {
angular.forEach(value.article, function (articleValue, articleKey) {
articleValues.push(articleValue)
});
}
}
});
obj.story = storyValues;
obj.article = articleValues;
$scope.flattenedResults.push(obj);
});
};
$scope.jsonFlatten(); //calling the method jsonFlatten() and making the flatten json
});