i think Json objects*. *For example
Here is my sample code:
*Student.Service.ts:*
..............
..............
export class Student {
constructor(public TitleId: number, public Title: string, public
NameId: number, public Name: string) { }
}
@Injectable()
export class StudentService {
getStudent(Id: number) {
return this.http.get(......).map(res => res.json());
}
}
*Student-Component.ts:*
................
................
export class StudentComponent implements OnInit {
................
................
Data: Student[];
ngOnInit() {
.............
this._service.getStudent(id).subscribe(result =>
{
this.Data = result;
*?????? Merge Duplicate Object*
});
}
}
*Student.html:*
...........
...........
<div *ngFor="#info of Data">
<b>{{info.Title}}</b>
{{info.Name}}
</div>
*Output:*
*Test111 *
KANE
*Test111 *
BOB
*Test111 *
SMITH
*Test222 *
KANE
*Test333 *
SMITH
But i want to display output like this:
*Test111*
KANE
BOB
SMITH
*Test222*
KANE
*Test333*
SMITH
Here is my default JSON object:
[
{
"TitleId":1,
"Title": "Test111",
"NameId":1,
"Name":"KANE"
},
{
"TitleId":1,
"Title": "Test111",
"NameId":2,
"Name":"BOB"
},
{
"TitleId":1,
"Title": "Test111",
"NameId":3,
"Name":"SMITH"
},
{
"TitleId":2,
"Title": "Test222",
"NameId":1,
"Name":"KANE"
},
{
"TitleId":3,
"Title": "Test333",
"NameId":3,
"Name":"SMITH"
},
]
and oh yes i think its better json needs to change object as below:
[
{
"TitleId":1,
"Title": "Test111",
* "NameId":[1,2,3], "Name":["KANE","BOB","SMITH"]*
},
{
"TitleId":2,
"Title": "Test222",
"NameId":1,
"Name":"KANE"
},
{
"TitleId":3,
"Title": "Test333",
"NameId":3,
"Name":"SMITH "
},
If Title is duplicated
On Tuesday, March 22, 2016 at 10:12:23 AM UTC+5, Sander Elias wrote:
>
> Hi Adnan,
>
> So, is your question how to dedupe some JSON objects, or something else?
>
> Regards
> Sander
>
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.