I have a case here
I have an observable array, and i have a single component, which is to vouch for the presence of a value in the given observable array and change the css if it exists so.
for ex in this script i am to check, if the word "hello" exists in the array and if it does than change the css to blue
SCRIPT
function VM() {
var arrInterests = 'hello,world'.split(',');
this.interests = ko.observableArray(arrInterests);
};
ko.applyBindings((new VM()));
HTML
<p class="green" data-bind="css: { 'blue': interests() === 'hello'}">Hello exists:
</p>
CSS
.green {
background-color: green;
border:2px solid red;
}
.blue {
background-color: blue;
border:2px solid red;
}