I am trying to retrieve a specific index in an array using the ng-repeat directive.
Currently, it is displaying information for all indexes... I only want to display the information for the second index as an example...
This is my main.js:
app.controller('ProviderController', ['$http', '$scope', function($http, $scope) {
var provider = this;
//Get service from API
$http({
url: 'http://private-5d90c-kevinhiller.apiary-mock.com/angular_challenge/horror_movies',
method: "GET",
}).success(function(data) {
//process received Data with the processMovie function
var providers = processMovies(data);
//process Data with the calculatePercentage function
var percentages = calculatePercentage(providers, data.length);
var providerKeys = [];
for(key in providers) {
providerKeys.push(key);
}
$scope.providerKeys = providerKeys;
$scope.providers = providers;
$scope.percentages = percentages;
})
}]);
function processMovies(data) {
var providers = [],
movie,
offer;
var total = data.length;
for(var i = 0; i < data.length; i++) {
//Process movies and offers here
}
return providers;
}
My Html:
<div ng-controller="ProviderController as provider">
<!-- Include provider controller from Angular-->
<div ng-repeat="providerId in providerKeys">
//Code inside nested div here
</div>
<div ng-repeat="(provider_id, value) in providers track by $index">
//Nested div content here
</div>
</div>;
I am currently getting information for all movies from all providers. How can I modify the Angular directive to only fetch the ones from a specific provider, such as provider 2? Thank you!