text: (function() {
      angular
          .module('xApp')
          .directive('entryShare', entryShareDirective);
  
      function entryShareDirective() {
          return {
              restrict: 'E',
              template:
                  '<a ng-click="share()" class="btn btn-success btn-xs" title="Share to User">' +
                      '<i class="glyphicon glyphicon-link"></i> Share' +
                  '</a>',
              scope: {
                  entry: '='
              },
              controller: function($rootScope, $scope, $modal) {
                  $scope.share = shareEntry;
  
                  function shareEntry() {
                      $modal.open({
                          templateUrl: 'entry/share.html',
                          controller: 'ModalShareController',
                          resolve: {
                              users: function(Api) {
                                  return Api.user.query();
                              },
                              access: function(Api) {
                                  return Api.share.query({id: $scope.entry.id});
                              },
                              entry: function() {
                                  return $scope.entry;
                              },
                              teams: function(Api) {
                                  return Api.team.query();
                              },
                              entryTeams: function(Api) {
                                  return Api.entryTeams.query({id: $scope.entry.id});
                              }
                          }
                      }).result.then(function (model) {
                          $rootScope.$broadcast('entry:share', model);
                      });
                  }
              }
          };
      }
  })();
  