ng-click

Mattepuffo's logo
Usare finestre modali in AngularJS

Usare finestre modali in AngularJS

Oggi vediamo come usare finestre modali con AngularJS.

In pratica, cliccando su un tasto, vedremo il dettaglio di un record nella finestra modale.

Partiamo quindi dalla tabella che espone i dati:

                    <table class="table table-bordered table-condensed table-striped">
                        <thead>
                            <tr>
                                <th>Titolo</th>
                                <th>Autore</th>
                                <th>Editore</th>
                                <th></th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr ng-repeat="book in books| filter:searchText">
                                <td>{{book.title}}</td>
                                <td>{{book.author}}</td>
                                <td>{{book.editor}}</td>
                                <td>
                                    <button type="button" class="btn btn-sm btn-primary"
                                            ng-click="open(book)">Dettaglio</button>
                                </td>
                            </tr>
                        </tbody>
                    </table>

Su come prendere i dati potete vedere questo articolo (anche se non usiamo una table in quel caso, ma il concetto è uguale).