function createDatepickerInstance(template) {
  var outputElement = $compile(template)(pageScope);
  pageScope.$apply();

  ngElement = outputElement[0].tagName === 'MD-DATEPICKER' ?
    outputElement : outputElement.find('md-datepicker');
  element = ngElement[0];
  scope = ngElement.isolateScope();
  controller = ngElement.controller('mdDatepicker');

  return outputElement;
}
Compile and link the given template and store values for element, scope, and controller.
@param {string} template
@returns {JQLite} The root compiled element.