UNPKG

1.17 kBJavaScriptView Raw
1/**
2 * ngTable: Table + Angular JS
3 *
4 * @author Vitalii Savchuk <esvit666@gmail.com>
5 * @url https://github.com/esvit/ng-table/
6 * @license New BSD License <http://creativecommons.org/licenses/BSD/>
7 */
8ngTableColumnsBinding.$inject = ["$parse"];
9/**
10 * One-way data binds the $columns array generated by ngTable/ngTableDynamic to the specified
11 * expression.
12 * This allows the $columns array created for the table to be accessed outside of the html table
13 * markup.
14 *
15 * @ngdoc directive
16 *
17 * @example
18 * ```html
19 * <table ng-table="$ctrl.tableParams" class="table" ng-table-columns-binding="$ctlr.tableColumns">
20 * ```
21 */
22export function ngTableColumnsBinding($parse) {
23 var directive = {
24 restrict: 'A',
25 link: linkFn
26 };
27 return directive;
28 function linkFn($scope, $element, $attrs) {
29 var setter = $parse($attrs.ngTableColumnsBinding).assign;
30 if (setter) {
31 $scope.$watch('$columns', function (newColumns) {
32 var shallowClone = (newColumns || []).slice(0);
33 setter($scope, shallowClone);
34 });
35 }
36 }
37}
38//# sourceMappingURL=ngTableColumnsBinding.directive.js.map
\No newline at end of file