IOnicpopup button in header, alternate of ionicModal not working due to compile/link issue


I want to but a button in a ionic popup before heading(title) but there isnt any clean option, is there any?

As an alternative, I tried to use ionicModal but when link function of a custom directive in that modal is called element is missing from dom, so selector return undefined

Code of model is

<script id="signature-modal.html" type="text/ng-template">
      <div angularcanvas></div>

and directive is:

    return {
            restrict: 'A',
         template: '<canvas id="canvas">Canvas is not supported</canvas>',
            link: function (scope, element, attrs) {
          var canvas = document.getElementById("canvas");
          console.log(document.getElementById('canvas')) //undefined
           canvasContext = canvas.getContext('2d');

Why canvas and getElementById shows undefined when link function is called, later the element can be seen in DOM?