我正在使用 Typescript 1.7、AngularJS 1.5.7、oclazyload 1.0.9、ui-grid 3.2.5、ui-router 0.3.1、requirejs 2.2.0
首先,一切正常,直到我从 Angular 1.4.3 升级到 1.5.7
在我的代码中,我从需要配置中提取源代码:
shim: {
'angular': {
exports: 'angular',
deps: ['Scripts/RequireJS/V.2.2.0/domReady!']
},
'ngSanitize': {
deps: ['angular']
},
'ngAnimate': {
deps: ['angular']
},
'ngTouch': {
deps: ['angular']
},
'uiRouter': {
deps: ['angular', 'ocLazyLoad']
},
'uiBootstrapTpls': {
deps: ['angular']
},
'ocLazyLoad': {
deps: ['angular', 'ngAnimate']
},
一旦 require 调用完成,我将配置 angular,然后手动调用 bootstrap。
用户进入登录页面,登录,然后转到主页。主页有一个 ui-grid,所以我们对状态变化进行延迟加载(oclazy loader),如下所示:
$ocLazyLoad.load('uiGrid');
注意 uiGrid 是在 angular 模块配置调用中配置的,如下所示:
$ocLazyLoadProvider.config({
events: true,
jsLoader: requirejs,
serie: true,
modules: [
{
name: 'uiGrid',
files: ['Scripts/AngularUIGrid/V.3.2.5/ui-grid.min']
}
现在这一切都可以使用 Angular 1.5.7 正常工作,但是如果我重新加载页面,我会得到这个:
TypeError: $$animateJs is not a function\n
at prepareAnimation (http://myServer/Scripts/Angular/V.1.5.7/angular-animate.js?bust=2016_6_12_12_24:2152:14)\n
at initDriverFn (http://myServer/Scripts/Angular/V.1.5.7/angular-animate.js?bust=2016_6_12_12_24:2136:16)\n
at invokeFirstDriver (http://myServer/Scripts/Angular/V.1.5.7/angular-animate.js?bust=2016_6_12_12_24:3234:24)\n
at Array.triggerAnimationStart (http://myServer/Scripts/Angular/V.1.5.7/angular-animate.js?bust=2016_6_12_12_24:3080:33)\n
at nextTick (http://myServer/Scripts/Angular/V.1.5.7/angular-animate.js?bust=2016_6_12_12_24:423:15)\n
at scheduler (http://myServer/Scripts/Angular/V.1.5.7/angular-animate.js?bust=2016_6_12_12_24:393:5)\n
at Array.<anonymous> (http://myServer/Scripts/Angular/V.1.5.7/angular-animate.js?bust=2016_6_12_12_24:3102:9)\n
at Scope.$digest (http://myServer/Scripts/Angular/V.1.5.7/angular.js?bust=2016_6_12_12_24:17338:55)\n
at Scope.$apply (http://myServer/Scripts/Angular/V.1.5.7/angular.js?bust=2016_6_12_12_24:17553:24)\n
at done (http://myServer/Scripts/Angular/V.1.5.7/angular.js?bust=2016_6_12_12_24:11698:47)
这在 1.4.3 Angular 中没有发生。
粗略地看一下,当发生这种情况时,这是因为在 angular-animate.js 中 $$animateJs 的 DI 未定义......因此显示的错误消息
var $$AnimateJsDriverProvider = ['$$animationProvider', function($$animationProvider) {
$$animationProvider.drivers.push('$$animateJsDriver');
this.$get = ['$$animateJs', '$$AnimateRunner', function ($$animateJs, $$AnimateRunner) {
oclazyload 是不是问题,我看了一点,不知道它装饰引导程序和模块的方式是否有帮助?
提前感谢您的帮助。