When Making a Directive for AngularJS

Worth Reading:  https://docs.angularjs.org/guide/directive

Especially this at the very bottom of that page:

Screengrab of Angular's explanation of link vs controller in a directive

By ‘expose an API’, they mean ‘add some this.doSomething() {…} functions to the controller that are reachable from outside the controller’.  Like public class methods.  If you’re not needing any of those, don’t add a controller to the directive.

Leave a Reply

Your email address will not be published. Required fields are marked *