【发布时间】:2017-06-21 18:46:19
【问题描述】:
我尝试了许多不同的方法来尝试让它发挥作用。 我已阅读:
ng-click not firing in AngularJS while onclick does
AngularJS : ng-click not working
还有更多
HTML:
<div ng-controller="testApp">
<div id="bla">
<button ng-click="obey('bla')">Close</button>
<h4>Bla bla bla</h4>
</div>
</div>
JS:
var testApp = angular.module('testApp', []);
testApp.controller('testController', function($scope) {
$scope.obey = function test(id) {
$("#" + id).fadeOut("slow", function() {
this.remove()
});
};
});
由于某种原因,div 根本没有淡出。
【问题讨论】:
-
只是一个提示,在使用 AngularJS 时应该避免 DOM 操作,请参考:stackoverflow.com/questions/14994391/…。使用 AngularJS 时不需要/推荐使用 jQuery。
标签: javascript jquery html angularjs