@@ -7,20 +7,21 @@ angular
7
7
*/
8
8
function MdTabsController ( $scope , $element , $window , $timeout , $mdConstant , $mdTabInkRipple ,
9
9
$mdUtil , $animate ) {
10
- var ctrl = this ,
11
- locked = false ,
12
- elements = getElements ( ) ,
13
- queue = [ ] ,
14
- destroyed = false ,
15
- loaded = false ;
10
+ var ctrl = this ,
11
+ locked = false ,
12
+ elements = getElements ( ) ,
13
+ queue = [ ] ,
14
+ destroyed = false ,
15
+ loaded = false ;
16
+
17
+ defineProperty ( 'focusIndex' , handleFocusIndexChange , $scope . selectedIndex || 0 ) ;
18
+ defineProperty ( 'offsetLeft' , handleOffsetChange , 0 ) ;
19
+ defineProperty ( 'hasContent' , handleHasContent , false ) ;
16
20
17
21
ctrl . scope = $scope ;
18
22
ctrl . parent = $scope . $parent ;
19
23
ctrl . tabs = [ ] ;
20
24
ctrl . lastSelectedIndex = null ;
21
- ctrl . focusIndex = $scope . selectedIndex || 0 ;
22
- ctrl . offsetLeft = 0 ;
23
- ctrl . hasContent = false ;
24
25
ctrl . hasFocus = false ;
25
26
ctrl . lastClick = true ;
26
27
ctrl . shouldPaginate = false ;
@@ -47,9 +48,6 @@ function MdTabsController ($scope, $element, $window, $timeout, $mdConstant, $md
47
48
48
49
function init ( ) {
49
50
$scope . $watch ( 'selectedIndex' , handleSelectedIndexChange ) ;
50
- $scope . $watch ( '$mdTabsCtrl.focusIndex' , handleFocusIndexChange ) ;
51
- $scope . $watch ( '$mdTabsCtrl.offsetLeft' , handleOffsetChange ) ;
52
- $scope . $watch ( '$mdTabsCtrl.hasContent' , handleHasContent ) ;
53
51
angular . element ( $window ) . on ( 'resize' , handleWindowResize ) ;
54
52
angular . element ( elements . paging ) . on ( 'DOMSubtreeModified' , ctrl . updateInkBarStyles ) ;
55
53
angular . element ( elements . paging ) . on ( 'DOMSubtreeModified' , updatePagination ) ;
@@ -286,6 +284,17 @@ function MdTabsController ($scope, $element, $window, $timeout, $mdConstant, $md
286
284
287
285
//-- Utility methods
288
286
287
+ function defineProperty ( key , handler , value ) {
288
+ Object . defineProperty ( ctrl , key , {
289
+ get : function ( ) { return value ; } ,
290
+ set : function ( newValue ) {
291
+ var oldValue = value ;
292
+ value = newValue ;
293
+ handler ( newValue , oldValue ) ;
294
+ }
295
+ } ) ;
296
+ }
297
+
289
298
function updatePagination ( ) {
290
299
ctrl . shouldPaginate = shouldPaginate ( ) ;
291
300
ctrl . shouldCenterTabs = shouldCenterTabs ( ) ;
0 commit comments