MCMXCVIII
MCMXCVIII

Reputation: 35

knockout foreach in html list

I have a problem, I don't know how to implement the foreach in html list. Here is my code:

<ul class="dropdown-menu">
    <li class="form-group col-sm-12 bg-orange">
        <p>Alert Messages</p>
    </li>
    <!-- ko: foreach: TopAlertMessage -->
    <li class="col-sm-12">
        <a href="#" class="row btn">
            <p data-bind="text: Message"></p>
        </a>
    </li>
    <!-- /ko -->
    <li class="form-group col-sm-12 alert-footer">
        <p class="row color-orange" data-bind="click: ClickViewAllTask">
            view all tasks
        </p>
    </li>
</ul>

TopAlertMessage Values are as follows:

enter image description here

and this is the list UI

enter image description here

Hope someone can help me.

Upvotes: 0

Views: 37

Answers (1)

Brother Woodrow
Brother Woodrow

Reputation: 6372

Your code looks fine, other than the fact there shouldn't be a : after ko in the comment tag:

<!-- ko foreach: TopAlertMessage -->

Upvotes: 2

Related Questions