material icon indicating copy to clipboard operation
material copied to clipboard

tabs: ‘md-selected="selectedIndex"’. How to make selectedIndex a global variable, that can be operated in various tab controllers?

Open PeaFull opened this issue 9 years ago • 7 comments

Actual Behavior:

  • What is the issue? *
  • What is the expected behavior?

CodePen (or steps to reproduce the issue): *

  • CodePen Demo which shows your issue:
  • Details:

AngularJS Versions: *

  • AngularJS Version:
  • AngularJS Material Version:

Additional Information:

  • Browser Type: *
  • Browser Version: *
  • OS: *
  • Stack Traces:

Shortcut to create a new CodePen Demo. Note: * indicates required information. Without this information, your issue may be auto-closed.

Do not modify the titles or questions. Simply add your responses to the ends of the questions. Add more lines if needed.

PeaFull avatar Apr 24 '17 06:04 PeaFull

I don't know how to control tab switching in other controllers

PeaFull avatar Apr 24 '17 06:04 PeaFull

image

PeaFull avatar Apr 24 '17 06:04 PeaFull

You could make your tab state a service, then inject the service into any controller you want to access or change the state from.

tyrdavis avatar Apr 24 '17 14:04 tyrdavis

@tyrdavis how to do it? thx!

PeaFull avatar Apr 25 '17 02:04 PeaFull

You can just make that a scope/controller variable.

md-selected="myVar" -> $scope.myVar = 2

DAquilina avatar Jun 13 '17 19:06 DAquilina

how will it work with controller As syntax?

ghost avatar Aug 16 '18 21:08 ghost

Thank you for taking the time to submit this issue. However there are better avenues for troubleshooting or asking for help with your app. These include Stack Overflow, Gitter, the AngularJS Material forums, etc.

Please limit GitHub issues to bug reports and enhancement requests.

Splaktar avatar Sep 04 '18 14:09 Splaktar