tag:blogger.com,1999:blog-9210025386133363283.post7530295088646884155..comments2023-12-18T02:17:56.198-08:00Comments on Modern JavaScript: Get current directive controller in AngularJSrhysbrettbowenhttp://www.blogger.com/profile/05642824819846878549noreply@blogger.comBlogger6125tag:blogger.com,1999:blog-9210025386133363283.post-615663635711713802015-04-02T13:32:18.349-07:002015-04-02T13:32:18.349-07:00functionalityfunctionalityAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-9210025386133363283.post-64972560921799018412014-08-07T20:15:41.809-07:002014-08-07T20:15:41.809-07:00correction: element.controller(myDirectiveName)correction: element.controller(myDirectiveName)Gilhttp://gilbox.menoreply@blogger.comtag:blogger.com,1999:blog-9210025386133363283.post-24226892006818680002014-08-07T20:14:48.650-07:002014-08-07T20:14:48.650-07:00Just do: element.controller(myControllerName)Just do: element.controller(myControllerName)Gilhttp://gilbox.menoreply@blogger.comtag:blogger.com,1999:blog-9210025386133363283.post-21915853495502462982014-05-12T07:17:01.832-07:002014-05-12T07:17:01.832-07:00That is the proper way to get it if you know the n...That is the proper way to get it if you know the name assigned to the directive.<br /><br />I was trying to solve this problem in the same context as my previous post where I provide the factory but a user could register the directive under a different name. In that case you can't have the name under require without the user providing it first, or you need to do it within the link function (as above) and grab the name from the directive object (instead I just gave the name in a variable in the example).Anonymoushttps://www.blogger.com/profile/10973562759155102343noreply@blogger.comtag:blogger.com,1999:blog-9210025386133363283.post-55110895439354169572014-05-11T11:58:22.075-07:002014-05-11T11:58:22.075-07:00The proper way to do this: https://gist.github.com...The proper way to do this: https://gist.github.com/justindujardin/19767e8ea72ccd2f41d3Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-9210025386133363283.post-51279107899362691192014-04-17T10:05:13.371-07:002014-04-17T10:05:13.371-07:00NIce - works! Great job figuring that out.
I'...NIce - works! Great job figuring that out.<br /><br />I'm wondering how to do this less "hackily" - no offense intended. <br /><br />Have you heard of other solutions?Anonymousnoreply@blogger.com