Added if-statement around possible undefined value.

On initial load, $history.activeIndex might be -1.  If it is, currentHistoryEntry will be undefined.