JSFiddle - React, Tailwind, and code Playground
by cgough
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.4.2/knockout-min.js"></script>
<div>
<span data-bind="css: $root.getChannelIcon"></span>
<span>Channel</span>
</div>
JavaScript
this.getChannelTypeIcon = ko.observable();
this.channels = ko.observableArray();
this.channels= [
"Email", "Chat", "Call"
];
this.getChannelTypeIcon = function (channel) {
var self = this;
if (channel.Type() == 0) {
alert("im a call");
return "icon icon-phone";
}
if (channel.Type() == 1) {
return "icon icon-bubble-dots2";
}
if (channel.Type() == 2) {
return "icon icon-at-sign";
}
}