Eusebiu Schipor Let’s talk tech!

  • Our directive need a controller.
  • bindToController: Attach scope properties to controller instead of directly to $scope.
  • controller: A function that will implement the controller.
  • controllerAs: Give a name to controller to use it in the template to refer to the controller instance.
  • Sometimes we want our directive to do more just serving a template holder.


Sometimes we want our directive to do more just serving a template holder. In this case, our directive need a controller. We need to provide another properties on our directive definition:


@eusebiuschipor: How to use controllers inside directives in AngularJS 1.x #angularjs #frontend

Congrats! Your email was added to our subscribers list!

Your email already exists in our database!

Posted on January 05, 2017

Sometimes we want our directive to do more just serving a template holder. In this case, our directive need a controller. We need to provide another properties on our directive definition:

Now we can use in our directive, the properties from our controller:

Note that I used one-way binding in my directive, to not change the values from controller.

Eusebiu Schipor Let’s talk tech!

You might also like More from author

Comments are closed, but trackbacks and pingbacks are open.