Is it possible to data-bind visible to the negation (“!”) of a boolean ViewModel property?

前端 未结 8 962
清歌不尽
清歌不尽 2020-12-23 15:24

I\'d like to use a property on my ViewModel to toggle which icon to display without creating a separate computed property of the inverse. Is this possible?



        
8条回答
  •  时光说笑
    2020-12-23 16:15

    It's little confusing, as you have to do

    visible:!showMe()
    

    so, i did

    Show
    Hide
    

    my model is

    var myModel={
        showMe:ko.observable(true)
    }
    ko.applyBindings(myModel);    
    

    ​ check in fiddle http://jsfiddle.net/khanSharp/bgdbm/

提交回复
热议问题