Differences between returning an object vs a function in a directive definition?

Returning only a function in a directive is just a shorthand for the link function in the full definition.

If you are specifying something other than a link function (like templateUrl) then you need to write it the long way:

angular.module("app").
    directive("widgetUno", ["$http", function ($http) {
        return {
          link: function(scope, element, attrs) {
             // A whole bunch of crap going on here
          },
          templateUrl: "widgetUno.html"
        };
    }]);

This difference is actually documented here – http://docs.angularjs.org/guide/directive

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)