Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Commit

Permalink
fix(tabs): select/deselect methods will now be called in the proper
Browse files Browse the repository at this point in the history
scope

Closes #2489
  • Loading branch information
Robert Messerle committed Apr 27, 2015
1 parent 59015b0 commit 02a4af5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/components/tabs/js/tabDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ function MdTab () {
label: '@',
active: '=?mdActive',
disabled: '=?ngDisabled',
select: '&?mdOnSelect',
deselect: '&?mdOnDeselect'
selectExpr: '@?mdOnSelect',
deselectExpr: '@?mdOnDeselect'
},
link: postLink
};
Expand All @@ -81,8 +81,8 @@ function MdTab () {
label: getLabel()
}, index);

scope.deselect = scope.deselect || angular.noop;
scope.select = scope.select || angular.noop;
scope.deselect = function () { ctrl.parent.$eval(scope.deselectExpr || ''); };
scope.select = function () { ctrl.parent.$eval(scope.selectExpr || ''); };

scope.$watch('active', function (active) { if (active) ctrl.select(data.getIndex()); });
scope.$watch('disabled', function () { ctrl.refreshIndex(); });
Expand Down

11 comments on commit 02a4af5

@gkalpak
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not & ? Isn't this what it's for ?

@robertmesserle
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When using &, it was being evaluated in the wrong scope.

@jo-me
Copy link

@jo-me jo-me commented on 02a4af5 Apr 29, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still the wrong scope, though:

#2600

"ctrl" needs to be the tab not md-tabs as it is currently.

@robertmesserle
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jo-me Resolved this issue this morning, thanks for calling it out.

@ismarslomic
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this fix released? Im still facing the same issue in v0.9.0

@jo-me
Copy link

@jo-me jo-me commented on 02a4af5 May 13, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me in the situation with tabs populated with ng-repeat and the ng-repeat iterator used as parameter in the md-on-select expression.

The very first select event is still missing, though.

@ismarslomic
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alert() below is never fired. Using v0.9.0.

<md-tabs> <md-tab md-on-select="alert('hello world')" label="Tab 1"></md-tab> </md-tabs>

Also, the expression in md-on-select is not evaluated at all. I can replace alert() with "blah blah" and no error will be showed in console.

@bonatoc
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jo-me

"and the ng-repeat iterator used as parameter in the md-on-select expression"

Please, could you be more specific? How do you use the iterator as a parameter and why?

@xzegga
Copy link

@xzegga xzegga commented on 02a4af5 Dec 8, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this fix in production yet? I have version 1.1.1 and the problem persist.

@devner007
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have version v1.1.3 and the problem exists as of date :(

@ericbiewener
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug appears to still be present in v1.1.4. I tried working around it by using an <md-tab-label> with ng-click on it, as well as on an inner <div>, but still no dice.

Please sign in to comment.