Here is a snippet of the code I've been working on:
var myApp = angular.module('myApp',[]);
//myApp.directive('myDirective', function() {});
//myApp.factory('myService', function() {});
myApp.controller('MyCtrl', ['$scope', MyCtrl]);
function MyCtrl($scope) {
$scope.name = 'Superhero';
$scope.names = [
{
"name": "AAAAAA",
"down": "False"
},
{
"name": "BBBBBB",
"down": "45%"
},
{
"name": "CCCCC",
"down": "12%"
}
];
$scope.datas = [
{
"data": "AAAAAA/45%"
}
];
$scope.getTheRightData = data => $scope.datas.map(d=>d.data.split('/')[0]).find(d=>d===data);
}
Some HTML
<div ng-controller="MyCtrl">
<table>
<tbody>
<tr ng-repeat="name in names">
<td>{{name.name}}</td>
<td>{{name.down}}</td>
<td ng-bind="getTheRightData(name.name)"></td>
</tr>
</tbody>
</table>
In my current setup, an element from $scope.datas
should match with an element from $scope.names
, but it only displays when name.name
matches. I am trying to implement a scenario where not only name.name
should match, but also name.down
. This involves using something like this:
<td ng-bind="getTheRightData(name.name,name.down)"></td>
, and modifying the controller function accordingly
$scope.getTheRightData = data => $scope.datas.map(d=>d.data.split('/')[0][1]).find(d=>d===data);
}
However, this approach is not functioning as expected. I would appreciate any suggestions or insights on how to resolve this issue. Thank you!