app.directive('toggle', function(){
  return {
    restrict: 'A',
    template: '<a ng-click="f()">Click Me</a>',
    replace: true,
    scope: {
      toggle: '&'
    },
    controller: function($scope) {
      $scope.toggleValue = false;
      $scope.f = function() {
        $scope.toggleValue = !$scope.toggleValue;
        $scope.toggle({message: $scope.toggleValue});
      };
    }
  };
});

You can use like this:

<div toggle="parentToggle(message)"></div>

相关文章:

  • 2022-12-23
  • 2022-01-02
  • 2021-06-19
  • 2021-12-06
  • 2021-09-20
  • 2021-12-17
  • 2021-10-07
  • 2022-12-23
猜你喜欢
  • 2021-12-05
  • 2021-06-26
  • 2021-09-08
  • 2022-12-23
  • 2021-08-15
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案