2016-08-19 24 views
1

我越來越AngularJS - 無法執行的「元素」「動畫」:部分關鍵幀,不支持

Error: Failed to execute 'animate' on 'Element': Partial keyframes are not supported.

而動畫NG-click方法裏面DOM元素。我使用$ event在ng-click中傳遞DOM參考。

這裏是小提琴鏈接 - fiddle containing issue

$event.currentTarget.animate({ 
    'height': '400px', 
    'width': '400px' 
    }); 

雖然我可以用jQuery的動畫我的DOM元素 - working fiddle

$($event.currentTarget).animate({ 
    'height': '400px', 
    'width': '400px' 
    }, 1000); 

我不能弄清楚爲什麼它不與工作簡單的角碼。

+0

有你'包括NG-animate'&'jQuery'爲你使用'$'? –

+0

是的,我已經包含了jQuery(不使用ng-animate)來獲得我在第二個小提琴中提到的解決方案。但不是第一個。 –

+1

在角度前使用'angular.element($ event.target)'並加載'jQuery'。 –

回答

1

jQLite不提供animate方法開箱,如果你想要它,那麼你必須有負載jQuery(角JS之前,讓angular.element也將有jQuery方法)。

其他角度方式的解決方案將是你可以加載ng-animate模塊&有登記在myApp模塊。你並不需要有ng-click處理過element

//below animation would apply on `container` class 
myApp.animation('.container', [function() { 
    return { 
    click: function(element, doneFn) { 
     angular.element(element).animate({ 
     'height': '400px', 
     'width': '400px' 
     }); 
    } 
    } 
}]);