Office.initialize引发了$ rootScope:infdig

时间:2017-12-31 13:32:53

标签: angularjs ms-office office-js html5-history office-app

以前,我的插件在不同的浏览器中运行良好。最近,在某些浏览器中它加载不好(控制台中的错误消息+只是在UI中显示空白页);在某些浏览器中加载,但在控制台中有错误消息。奇怪的是它在localhost中运行良好,但在生产中却不行。这是最小代码:

console.log("OfficeHelpers.Utilities.host: " + OfficeHelpers.Utilities.host);
console.log("OfficeHelpers.Utilities.platform: " + OfficeHelpers.Utilities.platform);

Office.initialize = function (reason) {
    jQuery(document).ready(function () {
        angular.bootstrap(document, ['test']) // it is important to not write 'ng-app="test"' in index.html, otherwise controller will be executed twice
        console.log("bootstrapped inside Office.initialize!");
    })
}

test = angular.module('test', ['ui.router']);
test.config(['$stateProvider', '$locationProvider', function ($stateProvider, $locationProvider) {
    $stateProvider
        .state('addinHomePlus', {
            url: '/addin/homePlus',
            template: 'testtest!!!'
        })
    $locationProvider.html5Mode(true);
}])

在Chrome中,它在用户界面中显示空白页面,此处显示的是$rootScope:infdig的错误消息:

enter image description here

有谁知道错误是什么?

编辑1:我使用https://cdn.rawgit.com/devote/HTML5-History-API/master/history.js来帮助html5模式。如果我设置$rootScopeProvider.digestTtl(3),我收到$rootScope:infdig的以下消息:

3 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations: [null,[{"msg":"fn: function (){var a=jb(c.url()),b=jb(l.absUrl()),f=c.state(),g=l.$$replace,m=a!==b||l.$$html5&&e.history&&f!==l.$$state;if(q||m)q=!1,d.$evalAsync(function(){var b=l.absUrl(),c=d.$broadcast(\"$locationChangeStart\",b,a,l.$$state,f).defaultPrevented;l.absUrl()===b&&(c?(l.$$parse(a),l.$$state=f):(m&&h(b,g,f===l.$$state?null:l.$$state),\nk(a,f)))});l.$$replace=!1}"},{"msg":"fn: function (){return d.hash()}","newVal":""}]]

1 个答案:

答案 0 :(得分:0)

如果我不使用URL(fileURLWithPath: #file).lastPathComponent ,此https://cdn.rawgit.com/devote/HTML5-History-API/master/history.js将会消失。但我确实需要$rootScope:infdig here