I want to set the css property using if condition using a normal variable other than observables. Like:
a.html file:
<span class="label" data-bind="text: isApproved, css: sampleglobalvar == true ? 'label-success' : 'label-important'"></span>
a.js file:
Edit:
define('durandal/app'],function(app) {
var a = function() {
sampleglobalvar = 'true'
};
}
I am getting an error such as 'sampleglobalvar' doesnt exist in viewmodel . I know that a observable has to be used , but I have other problems with observable where switching between 'true' and 'false' for observables was creating problems:
Like if I use:
sampleglobalvar = ko.observable("");
setting :
if(//condition)
{
sampleglobalvar(true);
}
else
{
sampleglobalvar(false);
}
was not clearing the observable properly , due to which I am getting different results.
To summarize is it possible to use a normal javascript variable to use it in css data-bind property?