UNPKG

can

Version:

MIT-licensed, client-side, JavaScript framework that makes building rich web applications easy.

34 lines (28 loc) 671 B
<body> <div id="out"></div> <script src="../../node_modules/steal/steal.js" dev-bundle main="@empty"> import { Component, stache, DefineMap} from "can"; const demoHtml = `Page {{ page() }} <button on:click='next()'>Next</button>`; const ViewModel = DefineMap.extend({ offset: { default: 0 }, limit: { default: 20 }, next: function(){ this.offset = this.offset + this.limit; }, page: function(){ return Math.floor(this.offset / this.limit) + 1; } }); Component.extend({ tag: "my-paginate", ViewModel: ViewModel, view: stache(demoHtml) }); const out = document.getElementById("out"); out.appendChild(stache("<my-paginate/>")({})); </script> </body>