Uncaught TypeError: Cannot read property 'register' of undefined

643 views
Skip to first unread message

vinod...@questglt.com

unread,
May 18, 2018, 7:03:50 AM5/18/18
to KnockoutJS
<!DOCTYPE html>
<head runat="server">
    <title></title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js" type = "text/javascript"></script>
         type = "text/javascript"></script>
</head>
<body>
<h4>First instance, without parameters</h4>
<div data-bind='component: "message-editor"'></div>
 
<h4>Second instance, passing parameters</h4>
<div data-bind='component: {
    name: "message-editor",
    params: { initialText: "Hello, world!" }
}'></div>
</script>

    <script>
ko.components.register('message-editor', {
viewModel: function(params) {
this.text = ko.observable(params && params.initialText || '');
},
template: 'Message: <input data-bind="value: text" /> '
+ '(length: <span data-bind="text: text().length"></span>)'
});
 
ko.applyBindings();
</script>
</body>
</html>

SLG

unread,
May 21, 2018, 5:36:19 PM5/21/18
to KnockoutJS
I think you are using knockout 3.1.0

component was added on knockout 3.2.0
Reply all
Reply to author
Forward
0 new messages