ViewModel:
define(['knockout',], function (ko) {
return {
Host: ko.observable("http://www.example.com")
};
});
查看:
<input type="text" data-bind="value: Host, valueUpdate: 'afterkeydown'" />
以上成功显示了“主机”值,我可以更改输入。但是输入值变得毫无用处,因为我的viewModel中的主机值仍然是默认值example.com
如何使用valueUpdate覆盖此默认值?
PathService.js
var servicesPath = config.companyPath;
var webRoot = config.Host;
var companyRoot = webRoot;
function setCompanyHost(url) {
webRoot = url;
}
function setCompanyHost(url) {
companyRoot = url;
}
function setServicesPath(path) {
servicesPath = path;
}
function getCompanySegment(companyName) {
return new uri(companyRoot)
.segment(servicesPath)
.segment('companies')
.segment(companyName);
}