lundi 28 septembre 2015

Knockout - show table if the array.length is bigger than 0

I need to display a message if the array is empty, otherise I need the data displayed in the table.

Here is what I have so far

 <div data-bind="if: interruptions().length == 0">No service interruption has been scheduled</div>

                        <table id="newsTbl" class="display compact table-bordered table-striped table-condensed table-hover" style="width: 100%">
                            <thead>
                                <tr>
                                    <th>Title</th>
                                    <th>Body</th>
                                    <th>Extra</th>
                                    <th>Start Date</th>
                                </tr>
                            </thead>
                            <tbody data-bind="foreach: interruptions">
                                <tr>
                                    <td data-bind="text: title"></td>
                                    <td data-bind="text: body"></td>
                                    <td data-bind="text: extra"></td>
                                    <td data-bind="text: startDate"></td>
                                </tr>
                            </tbody>
                        </table>

How do I add else in here?

Aucun commentaire:

Enregistrer un commentaire