D
D
Deodatuss2015-06-18 15:03:50
Angular
Deodatuss, 2015-06-18 15:03:50

Why do we need the require property in the directive?

Hello. I can't figure out what the require property is used for and what its use is. As I understand it, it requests a specific angular object and inserts it into the 4th argument of the link function. Did I understand correctly? And if so, can you explain what is the benefit of this and in what situations is it better to use this property? I understand that everything is in the documentation, but I would like to ask people practicing angular. Thanks in advance.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Mikhail Osher, 2015-06-18
@miraage

1) custom validators - use require ngModel
2) nested directives
3) ...

_
_ _, 2015-06-18
@AMar4enko

Requests not an object, but a controller instance of a directive at the same level of the hierarchy or higher in the DOM. Moreover, it can request not one controller, but several.
Used to organize interaction between directives.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question