-1

just see the two approach and tell me what is the difference. when which one should use ? in first case instance will be created but in second case no instance will be created at the time of ko.applyBindings() so here is the code.

function MyViewModel() { var self = this; self.lastInterest = ko.observable(); self.places = ko.observableArray(['London', 'Paris', 'Tokyo']); // The current item will be passed as the first parameter, so we know which place was hovered over self.logMouseOver = function(place) { self.lastInterest(place); } } ko.applyBindings(new MyViewModel()); var viewModel = { detailsEnabled: ko.observable(false), enableDetails: function() { this.detailsEnabled(true); }, disableDetails: function() { this.detailsEnabled(false); } }; ko.applyBindings(viewModel); 
1
  • another small question that is knockout js is the library developed by google because when i go to knockout js forum then url looks like groups.google.com/group/knockoutjs. Commented Nov 20, 2013 at 11:08

1 Answer 1

-2

first code part is a function but second is a class based module design pattern code witch you can reach to parameters in second code !

check out this :

http://www.adequatelygood.com/JavaScript-Module-Pattern-In-Depth.html

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.