0
{
    "Search": [
        {
            "name": "akram",
            "roll": 101
        },
        {
            "name": "wasim",
            "roll": 102
        }
    ],
    "total": "two record"
}

I want to print like this:

akram 101
wasim 102
2
  • What did you try so far? See How to loop with *ngFor in array of objects? Commented Jan 31, 2021 at 14:18
  • yest but my object is different as your object can you see below my object {"Search":[ {"name":"akram","roll":101}, {"name":"wasim","roll":102} ],"total":"two record"} Commented Jan 31, 2021 at 14:21

1 Answer 1

5

Just use this:

<p *ngFor="let item of object.Search">{{item.name}} {{item.roll}}</p>

See the docs

Sign up to request clarification or add additional context in comments.

6 Comments

<li *ngFor="let movie of movieListItem.Search"> Cannot read property 'Search' of undefined Error occurs in the template of component MoviedasboardComponent.
What error, do you need to capitalize movieListItem.Search
----------Below is the code------------ .ts public movieListItem:movieItem[] : data store from subscribe method .service getList(): Observable<movieItem[]> { return this.http.get<movieItem[]>(this.movieRender); } .html <ul> <li *ngFor="let movie of movieListItem.Search"> {{movie.Title}} </li> </ul>
can you put the error message and the code into the question
Property 'Search' does not exist on type 'movieItem[]'. 5 <li *ngFor="let movie of movieListItem.Search">
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.