From the course: Angular: Building an Interface

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Creating a modified list

Creating a modified list - Angular Tutorial

From the course: Angular: Building an Interface

Start my 1-month free trial

Creating a modified list

- [Instructor] Our application is working pretty well, and it's responsive to searches, but there's a few problems that we need to clean up, and the main one is that if we do a search like this, and then we delete the query terms, the list here will never go back to its original state. And that's because on this line on app component dot ts, we are always modifying the original list. So once a list has been filtered to contain only the elements that match our query, it can never go back and be what it used to be. So what we need to do is create a temporary variable here, so I'm going to also delete this title, 'cause we don't really need that any more, and I'll call it modified list. It's also going to be sort of a clone of the original list, and I'll go all the way to the bottom and make sure that when I load the data, I load it into both of those objects. And so now what I'll do is when I search for something, instead of modifying the list, I'm going to modify the copy of the list…

Contents