How can one create a reusable model window in AngularJS?
I'd like it to be reusable in the sense that we trigger the modal window with a hyperlink and set the popup content based on the parameter passed. For example:
<div ng-controller="SampleCtrl">
<a ng-click="toggleModal('FirstParam')">first</a>
<a ng-click="toggleModal('SecondParam')">second</a>
<a ng-click="toggleModal('ThirdParam')">Third</a>
</div>
When the first link is clicked it would display a modal containing content related to "FirstParam", etc.
I've tried custom directives and using $parent but I don't know how to pass the parameter from the toggleModal function call into the custom directive.
How can I achieve a re-usable modal window that is similar to this example?
In particular, I would like to know:
- How can I pass variables from a controller function into a custom directive?
- Are there any good tutorials on reusable custom directives and scopes?
- Are there any other design patterns for reusable custom directives?