snipt

Ctrl+h for KB shortcuts

Markdown

AngularJS question about custom directives vs. controllers.

https://snipt.net/embed/1288c42764c0e7348a6ba48756e7296e/
/raw/1288c42764c0e7348a6ba48756e7296e/
1288c42764c0e7348a6ba48756e7296e
markdown
Markdown
8
2019-05-26T10:44:56
True
False
False
/api/public/snipt/53693/
angularjs-question-about-custom-directives-vs-controllers
<ul> <li>So when we change the <code>subtitles</code> object on this controller: <a href="https://github.com/pculture/unisubs/blob/dev/media/src/js/subtitle-editor/controllers/subtitle-list.js#L200">https://github.com/pculture/unisubs/blob/dev/media/src/js/subtitle-editor/controllers/subtitle-list.js#L200</a> , our new list renders a new set of li's: <a href="https://github.com/pculture/unisubs/blob/dev/templates/subtitles/subtitle-editor.html#L79-L90">https://github.com/pculture/unisubs/blob/dev/templates/subtitles/subtitle-editor.html#L79-L90</a></li> <li>In some cases, when this list renders, we want to pre-select <em>one</em> of the li's, using this method: <a href="https://github.com/pculture/unisubs/blob/dev/media/src/js/subtitle-editor/directives/subtitles.js#L36-L69">https://github.com/pculture/unisubs/blob/dev/media/src/js/subtitle-editor/directives/subtitles.js#L36-L69</a></li> <li>What I'm confused about is: what is the proper "Angular"-way to call a private method on a custom directive from within a controller? Or should that private method (onSubtitleItemSelected) be somewhere else?</li> </ul>
angular, angularjs