Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.26 KB | None | 0 0
  1. <ul class="nav nav-tabs">
  2. <li class="active"><a href="#/view1">Home</a></li>
  3. <li><a href="#/view2">Menu 1</a></li>
  4. </ul>
  5.  
  6. <div ng-view></div>
  7. <div>Angular seed app: v<span app-version></span></div>
  8.  
  9. 'use strict';
  10.  
  11. angular.module('myApp.view1', ['ngRoute'])
  12.  
  13. .config(['$routeProvider', function($routeProvider) {
  14. $routeProvider.when('/view1', {
  15. templateUrl: 'view1/view1.html',
  16. controller: 'View1Ctrl'
  17. });
  18. }])
  19.  
  20. .controller('View1Ctrl', [function() {
  21.  
  22. }]);
  23.  
  24. <div>here's some html</div>
  25.  
  26. <div class="container">
  27.  
  28. <div id="content">
  29. <ul id="tabs" class="nav nav-tabs" data-tabs="tabs">
  30. <li class="active"><a href="#red" data-toggle="tab">Red</a></li>
  31. <li><a href="#orange" data-toggle="tab">Orange</a></li>
  32. <li><a href="#yellow" data-toggle="tab">Yellow</a></li>
  33. <li><a href="#green" data-toggle="tab">Green</a></li>
  34. <li><a href="#blue" data-toggle="tab">Blue</a></li>
  35. </ul>
  36. <div id="my-tab-content" class="tab-content">
  37. <div class="tab-pane active" id="red">
  38. <h1>Red</h1>
  39. <p>red red red red red red</p>
  40. </div>
  41. <div class="tab-pane" id="orange">
  42. <h1>Orange</h1>
  43. <p>orange orange orange orange orange</p>
  44. </div>
  45. <div class="tab-pane" id="yellow">
  46. <h1>Yellow</h1>
  47. <p>yellow yellow yellow yellow yellow</p>
  48. </div>
  49. <div class="tab-pane" id="green">
  50. <h1>Green</h1>
  51. <p>green green green green green</p>
  52. </div>
  53. <div class="tab-pane" id="blue">
  54. <h1>Blue</h1>
  55. <p>blue blue blue blue blue</p>
  56. </div>
  57. </div>
  58. </div>
  59.  
  60. <div ng-if="vm.showTab2">
  61.  
  62. var vm = this;
  63. vm.showTab1 = true;
  64. vm.showTab2 = false;
  65.  
  66. vm.ToggleTab = function(tabId) {
  67. vm.showTab1 = tabId === ShowTab1;
  68. vm.showTab2 = tabId === ShowTab2;
  69. ...
  70. }
  71. ...
  72. init();
  73. function init() {
  74. // Get the tabID parameter from the URL (via $routeParams)
  75. var tabId = $routeParams.tabId;
  76. if (tabId !== undefined) {
  77. vm.ToggleTab(tabId);
  78. }
  79. ...
  80. }
  81.  
  82. .config(['$routeProvider', function($routeProvider) {
  83. $routeProvider.when('/view:tabId', {
  84. templateUrl: 'view1/view.html',
  85. controller: 'ViewCtrl'
  86. });
  87. }])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement