I have developing an Excel add-in by mean-stack. Long time ago, I saw an answer somewhere about starting up an AngularJS add-in with office.js (unfortunately I cannot find the thread anymore). The following solution was suggested, though I don't remember what the initial problem was:
Office.initialize = function (reason) {
jQuery(document).ready(function () {
angular.bootstrap(document, ['app'])
})
}
Now, I try to write <html ng-app="app"> and NOT use the above block (that allows me to lazy-load office.js). So far, it seems the add-in works as well.
So does anyone know if the <html ng-app="app"> way has any potential risk for an Excel add-in? Office.initialize is not mandatory, right?
Edit 1: I just realized that it did not work well in all the cases, here is the problem: Starting up an Excel add-in with ocLazyLoad failed in Excel for Windows.
Office.initializeis mandatory. The way that I've solved that problem was something like this.Using
$routeProviderconfigure your mapping of load controller to partial templateloading.html.The block so far ensures when you're on the default start of the add-in with
yourserver.org#/url you're showing the load controller. In the html of your load controller, just put a spinner. So when your app loads, but office.js is not initialized yet, you're showing the spinner.Now in your
LoadControlleryou will initialize office.js and redirect to another partial view.in the
LoadControllerwhere the'/'url of the angular app is showing just the loader. So the first template that you see is the loading template - but you're already in the angular app. When office.js initializes, it just points you to the actual experience.