I've been struggling to access a property of a service through a bound controller variable in a template.
Controller:
app.controller('VictoryController', function($scope, AlertStatisticsService) {
$scope.AlertStats = AlertStatisticsService;
});
The Service returns an object structured like this:
factory = {
factionWins = {
vs: 123,
nc: 123,
tr: 123
}
}
The template is rendered as part of an Attribute directive:
app.directive('homeVictoryCard', function() {
return {
restrict: 'A',
replace: true,
scope : {
empire: '@',
},
templateUrl: 'views/home/partials/victory.card.html'
};
});
This is called by the following HTML element:
<div home-victory-card empire="vs"></div>
In the template, I'm trying to access the object data using the empire
variable that is in the template's scope, like so:
{{ AlertStats.factionWins[empire] }}
I'm also attempting to use it in various ng-hide and ng-show directives, such as:
ng-hide="AlertStats.factionWins[empire] > 0"
Previously in Twig, I would use
attribute(AlertStats.factionWins, empire)
to get the information. However, I am uncertain how to do this in Angular, and my Google searches haven't provided any helpful results.
Thank you for your help!