GUI -- Table scrolling fixed header directive no longer depends on a timeout function.
- Added a general directive that emits when ng-repeat is completed.

Change-Id: I23131adecded9f0393334d003812845ac6b4f031
diff --git a/web/gui/src/main/webapp/app/fw/widget/table.js b/web/gui/src/main/webapp/app/fw/widget/table.js
index 062318f..5cf283e 100644
--- a/web/gui/src/main/webapp/app/fw/widget/table.js
+++ b/web/gui/src/main/webapp/app/fw/widget/table.js
@@ -113,7 +113,6 @@
             };
         }])
 
-        // TODO: find another solution other than timeout for waiting for ng-repeat to end
         .directive('onosFixedHeader', ['$window', '$timeout',
             'MastService', 'FnService',
             function (_$window_, $timeout, mast, _fs_) {
@@ -121,7 +120,8 @@
                 $window = _$window_;
                 fs = _fs_;
                 var w = angular.element($window),
-                    table = d3.select(element[0]);
+                    table = d3.select(element[0]),
+                    shouldResize = false;
 
                 scope.$watch(function () {
                     return {
@@ -136,10 +136,16 @@
                     scope.windowWidth = newVal.w;
 
                     scope.setTableHW = function () {
-                        $timeout(function () {
+                        scope.$on('LastElement', function (event) {
                             fixTable(table, thead, tbody);
-                        }, 250);
+                            shouldResize = true;
+                        });
                     };
+
+                    if (shouldResize) {
+                        fixTable(table, thead, tbody);
+                    }
+
                 }, true);
 
                 w.bind('onos-fixed-header', function () {