Friday, August 7, 2015

Office Javascript API and Angular JS HTML5 hash tag Url issue

I have faced very new and tricky issue with AngularJS and Office.js,

My app was working fine in HTML5Mode (i.e url without #) and all url navigated properly when only AngularJS JS file included.

But if i include Office App JavaScript API (aka Office AddIns) JS file (office.js), HTML5Mode stops working and Url shows with # tags. Means app worked without HTML5 History API, i found this using $sniffer.history in AngularJS. This returns as false.

Following two line of code made this problem, so to avoid this issue comment following lines in office.debug.js or office.js file

window.history.replaceState = null;
window.history.pushState = null;