I have successfully implemented some Angular code that is working, however, I am struggling to understand why it works. Coming from a C Sharp background and being new to JS and Typescript.
<tr ng-repeat="colleague in Model.FilteredColleagueListModel | filter:Model.searchText(Model.SearchCriteria)" >
public searchText(searchCriteria)
{
return function (item) {
if (item.DisplayName.indexOf(searchCriteria) > -1
{
return true;
}
return false;
}
};
One thing that puzzles me is the nested function. Why is 'item' only available within the return function? Also, I'm not sure if returning a function like this is the correct approach in TypeScript. Is it acceptable to ask more open-ended questions like these?