Advertisement
Guest User

Untitled

a guest
Oct 21st, 2014
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. <div ng-controller="TabsDemoCtrl">
  2. <tabs>
  3. <pane ng-repeat="pane in panes" heading="{{pane.title}}" active="pane.active">
  4. <div ng-include="pane.template"></div>
  5. </pane>
  6. </tabs>
  7. </div>
  8.  
  9. var TabsCtrl = function ($scope) {
  10. $scope.panes = [
  11. { title:"Events list", template:"/path/to/template/events" },
  12. { title:"Calendar", template:"/path/to/template/calendar" }
  13. ];
  14. };
  15.  
  16. <tabs>
  17. <pane ng-repeat="pane in panes" heading="{{pane.title}}" active="pane.active">
  18. {{pane.content}}
  19. </pane>
  20. </tabs>
  21.  
  22. $scope.active = function() {
  23. return $scope.panes.filter(function(pane){
  24. return pane.active;
  25. })[0];
  26. };
  27.  
  28. <tab active="tabActivity[0]">...</tab>
  29. <tab active="tabActivity[1]">...</tab>
  30.  
  31. $scope.tabActivity=[false,false];
  32.  
  33. $scope.tabActivity.indexOf(true)
  34.  
  35. $("#youTabIdHere> ul > li > a").on("click", function(evt){
  36. console.log(evt);
  37. });
  38.  
  39. $scope.active = function() {
  40. if ($scope.panes) {
  41. var i;
  42. for (i=0;i<$scope.panes.length;i++) {
  43. if ($scope.panes[i].active) {
  44. return i;
  45. }
  46. }
  47. }
  48. };
  49.  
  50. $scope.$watch('active()', function(paneIndex) {
  51. if (paneIndex != undefined) {
  52. var pane = $scope.panes[paneIndex];
  53. $scope.tabHandler(pane); // this would be your function on change
  54. }
  55. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement