I am wondering how can I get subject and body.
<a data-bind="attr: { href: 'mailto:' + 'test@test.com', **subject:'test', body:'test'** }">click</a>
Thank you
If email
, subject
, and body
are all separate observables in your viewmodel, then you can add a mailto
computed observable which can combine these for your href
attribute. For instance:
var ViewModel = function() {
this.email = ko.observable('test@test.com');
this.subject = ko.observable('test');
this.body = ko.observable('test');
this.mailto = ko.computed(function() {
return 'mailto:' + this.email() + '?subject=' + this.subject() + '&body=' + this.body();
}, this);
};
And then the anchor tag can be setup like so:
<a data-bind="attr: { href: mailto }">click</a>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.