转换Jquery日历按钮单击角度指令

时间:2015-01-21 08:24:56

标签: jquery angularjs

我想将我的jquery按钮单击代码转换为angular指令。 我的代码是:

$('.fc-month-button').click();

1 个答案:

答案 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)
                      }
                  });
              }
          };