Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Angular js set default tab with ng-repeat in array object

var app = angular.module('myApp', []);
app.controller('myCtrl', function ($scope) {
  $scope.data = [
    {
      "tab": [
        [{ "id": 1, "status": 1 }, { "id": 2, "status": 1 }, { "id": 3, "status": 1 }],
        [{ "id": 4, "status": 1 }],
        [{ "id": 5, "status": 0 }]
      ]
    },
    {
      "tab": [
        [{ "id": 6, "status": 1 }, { "id": 7, "status": 1 }],
        [{ "id": 8, "status": 1 }]
      ]
    },
  ];
  for (let i = 0; i < $scope.data.length; i++) {
    $scope.data[i].selectedTab = $scope.data[i].tab[$scope.data[i].tab.length - 1];
  }

  $scope.setSelectedTab = function (node, tab) {
    tab.selectedTab = node;
  };
});
Comment

Angular js set default tab with ng-repeat in array object

.active {
  color: red;
}
Comment

Angular js set default tab with ng-repeat in array object

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
<div ng-app="myApp" ng-controller="myCtrl">
  <div ng-repeat="obj in data">
    <ul class="nav nav-tabs">
      <li ng-class="{ active: obj1[0] && obj.selectedTab == obj1 }" ng-repeat="obj1 in obj.tab track by $index">
        <a href ng-click="setSelectedTab(obj1, obj)">{{ $index }} </a>
      </li>
    </ul>
    <div class="tab-content" ng-repeat="tab in obj.selectedTab track by $index">
      ID: {{tab.id}}<br>
      Status : {{tab.status}}
    </div>
  </div>
</div>
Comment

PREVIOUS NEXT
Code Example
Javascript :: How to return $http.post() object with factory function 
Javascript :: Relaxed "angularjs" style expression parsing missing in vue 
Javascript :: Json response reactnative fetch login data 
Javascript :: React Native Root Element, deciding on async call 
Javascript :: Using useEffect with async 
Javascript :: Context: Cannot read properties of undefined 
Javascript :: how to send more than one array using response() json() in laravel 
Javascript :: How to check the increase/decrease of letter input in pasting clipboard in jQuery 
Javascript :: on veiwport reveal javascript 
Javascript :: reduce dot notations to javascript array 
Javascript :: Get value by key from json array 
Javascript :: p5 filter 
Javascript :: insert image in jsp page 
Javascript :: react text editor snippet 
Javascript :: online jquery converter 
Javascript :: Sending An AJAX Request Using Ky 
Javascript :: short-circuit evaluation , use of || operator 
Javascript :: Constructor for blockchain 
Javascript :: counter using redux 
Javascript :: photoshop Change image size JavaScript 
Javascript :: javascript complier 
Javascript :: Declaring A Method Outside The Constructor 
Javascript :: useDapp connect metamask example 
Javascript :: Update A Request() Property 
Javascript :: Exporting Objects with the Exports Object in electron 
Javascript :: how to create existing nodes in godot 
Javascript :: send form data to endpoint js 
Javascript :: Backbone View In Another View 
Javascript :: hide and show button react js 
Javascript :: jquery textarea value 
ADD CONTENT
Topic
Content
Source link
Name
7+3 =