Dynamic title attribute in knockoutjs
html, javascript, knockout.js
Solution
You cannot do this in such way. Create `computed` value in your view model that will return needed `title` depends on `isPublic` property:
self.title = ko.computed(function(){
return self.isPublic() ? 'mark private' : 'mark public';
});
Or you can do this inside `data-bind` attribute but it is not considered the best of solutions:
<span id="aPublic" class="pointer"
data-bind="attr:{title: isPublic() ? 'mark private': 'mark public'}">
</span>
Problem
I want to set title attribute of span dynamically. I have tried below: ``` <span id="aPublic" class="pointer" data-bind="attr:{title: {'mark private': isPublic, 'mark public': !isPublic()}}"> </span> ``` But it gives me [object Object].