How to stop ng-click from a custom directive in AngularJS?

前端 未结 4 894
臣服心动
臣服心动 2021-01-19 08:15

LIVE DEMO

Consider the following myButton directive:

angular.module(\"Demo\", []).directive(\"myButton\", function() {
  return {
    re         


        
4条回答
  •  庸人自扰
    2021-01-19 08:44

    Why not use the actual button for your button. You could change your directive to:

    angular.module("Demo", []).directive("myButton", function() {
      return {
        restrict : "E",
        replace: true,
        scope: {
          disabled: "="
        },
        transclude: true,
        template: ""
      };
    });
    

    Then style it to look like your div. See the Short Example I've made.

提交回复
热议问题