For very simple cases this should work:
<span data-bind="text: ProjectId < 10 ? '0' + ProjectId.toString() : ProjectId"></span>
Or move this logic to your model instead:
vm.paddedProjectId = ko.computed(function() {
return vm.ProjectId < 10 ? '0' + vm.ProjectId.toString() : vm.ProjectId;
});
This won't work for numbers below zero, nor will it pick up a dynamic number of zero's (e.g. if your numbers go beyond 100 you may want "005", etc). It may also have some iffy results with unexpected values for ProjectId
, such as the empty string. For those cases refer to the question mentioned in comments.
PS. The function you're using is Number.toString that expects a radix argument; useful in its own right but not quite what you're looking for I think.