In a factory I construct a HTML page. This page can contain a form, so I want to get a handle on the FormController. After some Googling I've got everything working with this line of code (html is all the html in a string in a jquery selector):
html.find("input").eq(0).controller('form');
I understand that:
- find(): it is going to find all the input elements;
- eq(): I suppose this will select the first found item of the find list;
- controller(): this part is unclear. I find it hard to find some documentation about this. What I do know is that you can pass
ngModelorform. When passingngModelyou get theFormControllerof the specified control, thus not the whole form. And when specifyingformyou get a reference to the whole form.
So, I understand the most of, but I still don't get if controller() is an Angular function or Jquery function and how/when you can use this method.
ngViewfor your problem, or a custom directive?