user3153878
user3153878

Reputation: 421

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

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?

Upvotes: 2

Views: 671

Answers (1)

Rahul
Rahul

Reputation: 5774

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.

Upvotes: 2

Related Questions