angularjs - Is passing a method as a string param to a directive not a bad thing? -
while discovering directives bumped on following: <div ng-app="twitterapp"> <div ng-controller="appctrl"> <div enter>roll on load more tweets</div> </div> </div> var app = angular.module('twitterapp', []); app.controller("appctrl", function ($scope) { $scope.loadmoretweets = function () { alert("loading tweets!"); } }) app.directive("enter", function () { return function (scope, element, attrs) { element.bind("mouseenter", function () { scope.loadmoretweets(); }) } }) they say: "it better practice decouple loadmoretweets() method entirely passing directive string parameter in view, , retrieving attrs parameter in directive." so becomes: <div ng-app="twitterapp"> <div ng-controller="appctrl"> div enter="loadmoretweets()">roll on load more tweets</div> </div> &