I generated a Knockout app using Yeoman which uses RequireJS to manage dependencies. I am not able to access some of the parameters from the parent function inside the closure. Here is the code:
define(["knockout", "jquery", "text!./home.html"], function (ko, $, homeTemplate) {
debugger;
// ko, $, homeTemplate are all defined here.
function HomeViewModel(route) {
debugger;
// only ko is defined here. $ and homeTemplate are undefined.
this.message = ko.observable('Welcome to Knockout!');
}
HomeViewModel.prototype.doSomething = function () {
this.message('You invoked doSomething() on the viewmodel.');
};
return { viewModel: HomeViewModel, template: homeTemplate };
});
Why am I not able to access $
and homeTemplate
parameters inside the closure?
Aucun commentaire:
Enregistrer un commentaire