1

I'm wondering what's the best place to set functions in a directive

//directive
app.directive("clickMe", function() {
                return {
                    restrict: "E",
                    templateUrl: 'clickMe.html',
                    controller: function ($scope) {
                        $scope.clickMe = function(){

                        }   
                    },
                    link: function (scope) {
                        scope.clickMe = function(){

                        }   
                    }

                }
            });
//template
<button ng-click="clickMe()">click me</button>

link or controller block ?

Whisher
  • 31,320
  • 32
  • 120
  • 201

0 Answers0