function compile(template) {
    var element = $compile(template)(scope);
    scope.$apply();
    $timeout.flush();
    return element;
  }
Compile a template synchronously
@param  {String} template The string to compile
@return {Object}          A reference to the compiled template