i display some model entities with ng-repeat like and add a twitter bootstrap modal. The modal contains a form:
<div class="entity" ng-repeat="entity in model" ng-click="openModal()">
<b>{{ model.title }}</b></br>
<i>{{ model.content }}</i>
</div>
<!-- bootstrap modal ... -->
<div id="modal" ....
What is the best practise to open a bootstrap modal (which contain a form), and display the data of the entity in the form?
First of all, pay attention that you have a bug in the example (entity.title not model.title).
As for the modal, you can create a directive called modal-window and pass the entity to it.
You can pass the entity through the openModal(entity), and have the modal window bind a property to it.
Something like
Controller:
$scope.entity = {};
$scope.showModal = false;
$scope.openModal = function( entity ){
$scope.entity = entity;
$scope.showModal = true;
}
template:
<modal-window entity="entity"></modal-window>