浏览代码

Copy from bootstrap-table-examples@b1f3912/integration/bsTable.js

Dan Kaplun 10 年之前
父节点
当前提交
7fba8eb5b6
共有 1 个文件被更改,包括 27 次插入0 次删除
  1. 27 0
      src/extensions/angular/bsTable.js

+ 27 - 0
src/extensions/angular/bsTable.js

@@ -0,0 +1,27 @@
+// JavaScript source code
+(function () {
+    angular.module('bsTable', [])
+   .directive('bsTableControl', function () {
+       return {
+           restrict: 'EA',
+           scope: {
+               options: '='
+           },
+           link: function (scope, element, attr) {
+               var tableCreated = false;
+               scope.$watch('options', function (newValue, oldValue) {
+                   if (tableCreated && newValue === oldValue) return;
+                   $(element).bootstrapTable('destroy');
+                   if (newValue) {
+                       $(element).bootstrapTable(scope.options);
+                   }
+                   tableCreated = typeof (newValue) !== 'undefined';
+               });
+               $(window).resize(function () {
+                   if (tableCreated)
+                       $(element).bootstrapTable('resetView');
+               })
+           }
+       };
+   })
+})();