'use strict';
var angular = require('angular');
require('../modules');
var module = angular.module('info.directives');

module.directive('sinoInfoTableView', function($ionicModal) {
  return {
    restrict: 'A',
    link: function(scope, element) {

      element.on('click', function() {
        var modalScope = scope.$new();
        modalScope.closeModal = function() {
          modal.hide();
          modal.remove();
        }

        var modal = $ionicModal.fromTemplate('<ion-modal-view>\
          <ion-header-bar class="bar-dark">\
            <button class="button icon-left ion-ios-arrow-back button-clear" sino-modal-back-button="closeModal()">返回</button>\
            <h1 class="title">查看表格</h1>\
          </ion-header-bar>\
          <ion-content scroll="true" direction="xy">' +
            element.html() +
          '</ion-content></ion-modal-view>', {
          scope: modalScope
        });
        modal.show();
      });
    }
  }
});
