我正在使用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
在我的代码中,我从require config中提取源代码:
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,所以我们懒得加载(oc lazy loader)状态改变如下:
$ocLazyLoad.load('uiGrid');
注意uiGrid是在角度模块配置调用中配置的,如下所示:
$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问题,我看了一下,不知道它是否装饰引导程序和模块可以贡献的方式?
提前感谢您的帮助。
答案 0 :(得分:-1)
ui.grid依赖于ngAnimate,因此您需要在加载ui.grid之前加载它。
resolve: helper.resolveFor('ngAnimate','ui.grid')
希望这有帮助。