angularUtils icon indicating copy to clipboard operation
angularUtils copied to clipboard

dir-paginate passes undefined to ng-if even when object is defined

Open Legion6789 opened this issue 8 years ago • 1 comments

It's hard for me to know which version of dir-paginate I have as it's not stated in the source. Whichever version was current as of Dec 13, 2015.

Edit: I just grabbed the latest version as of this posting off of github and the problem persists.

Description of issue: When using dir-paginate with ng-if the collection entry is always passed as undefined. If dir-paginate is replaced with ng-repeat everything works fine.

<tr class="table-rw-hover" dir-paginate="historyEntry in HistoryLog | orderBy:sort:reverse | itemsPerPage: 10" ng-if="isRequiredRoleToView(historyEntry.RequiredRoleToView)">

historyEntry is always passed to isRequiredRoleToView as undefined despite HistoryLog being fully populated with no null entries.

If I replace dir-paginate with ng-repeat then historyEntry is passed to isRequiredRoleToView properly (it's defined).

<tr class="table-rw-hover" ng-repeat="historyEntry in HistoryLog | orderBy:sort:reverse" ng-if="isRequiredRoleToView(historyEntry.RequiredRoleToView)">

Legion6789 avatar Mar 22 '17 18:03 Legion6789

Hi,

This is probably caused by the "magic" by which dirPaginate dynamically compiles itself into an ngRepeat at runtime. It generally works fine but in edge cases (such as this) the behaviour is not as you would expect.

I suggest, if possible, you try to find a way to structure your markup so that the ng-if is a child of the <tr>, which should work. I know this might be a pain to do. Sorry.

michaelbromley avatar Mar 22 '17 19:03 michaelbromley