我想将我的jquery按钮单击代码转换为angular指令。 我的代码是:
$('.fc-month-button').click();
答案 0 :(得分:0)
AngularJs控制器代码
var app = angular.module('myApp', []);
app.controller('MainCtrl', function($scope) {
$scope.yourFunction = function(){
//TODO
};
});
这是ng指令的代码示例
app.directive('ngClick', [
function () {
return {
link: function (scope, element, attr) {
var msg = attr.ngClick || "Are you sure?";
var clickAction = attr.confirmedClick;
element.bind('click', function (event) {
if (window.confirm(msg)) {
scope.$eval(clickAction)
}
});
}
};