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
  • 28,724
  • 30
  • 114
  • 190

0 Answers0