How replace data-bind tag with {{}} style bindings in KnockoutJS?

故事扮演 提交于 2019-12-21 22:01:21

问题


I want to declare my bindings as with AngularJS, but I'm using the KnockoutJS library. That is, I want to use Knockout but with the syntax I know from Angular. E.g.:

Today's message is: <span data-bind="visible:true,text:myMessage"></span>

I want to write using {{}} notation, like so:

Today's message is: <span {{visible:true,text:myMessage}}></span>

How can I replace data-bind attributes with {{}} based syntax in KnockoutJS?


回答1:


http://mbest.github.io/knockout.punches/ is all you need.

Knockout Punches convert traditional KO syntax to something like AngularJS

<div>Hello {{name}}.</div>

I personally find it very easy to use.



来源:https://stackoverflow.com/questions/29059204/how-replace-data-bind-tag-with-style-bindings-in-knockoutjs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!