How replace data-bind tag with {{}} style bindings

2020-07-25 01:34发布

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条回答
放荡不羁爱自由
2楼-- · 2020-07-25 01:46

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.

查看更多
登录 后发表回答