How do you define a custom directive in AngularJS?

Custom directives are user-defined DOM elements or attributes that extend HTML functionality. They’re registered with the directive method.

app.directive('myDirective', function() {
  return {
    template: '<p>This is a custom directive</p>'
  };
});