Reputation: 500
I would like to know how to achieve it. I have found
Here I found how it should be done, by modifying the component, not extending it but I really can't find how to do it in the code. More information would be great. How can I extend or modify the template of mat-calendar? Inside the mat-calendar code I can't find the template.
And in this second case I found how to add a button here2 but I have the same problem, do'nt know how to do it, could someone provide any exaple where I can see how to achieve it.
Upvotes: 1
Views: 1771
Reputation: 11081
This is an ugly way of doing it, but it shows how to complete the task via manipulating the document object.
Using the Opened event:
<mat-datepicker (opened)="opened()" #picker></mat-datepicker>
Component Method:
opened() {
var btn = document.createElement("button");
btn.onclick = function () {
alert("blabla");
};
var t = document.createTextNode("Click Me");
btn.appendChild(t);
var div = document.createElement("div");
div.appendChild(btn);
setTimeout(() => {
var element = document.getElementsByTagName('mat-datepicker-content');
element[0].appendChild(btn);
})
}
Upvotes: 5