I have setup my application based on a seed project and I am using Controller Alias (App.routes.js has controllerAS for each controller I am using so ::NE is a controller alias). I have a factory service and manager service that feeds data to the controller. Most of this seems to be working ok.
I am now trying to create a basic HTML view where I display a list of items on the page and when the user selects an item in the list it becomes highlighted (e.g. the CSS updates).
I have managed to get the data to display on the page but when I select an item in the list the CSS style is not updating. My code is below and a screenshot that shows some info I have written out to the log as I click on different items in the list.
node.html
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">List of Nodes</h3>
</div>
<div class="panel-body">
<div>
<div class="col-sm-4">
<h4>Nodes</h4>
<div class="list-group">
<a ng-repeat="node in ::NE.node" class="list-group-item" ng-class="{active: selected==node}" ng-click="NE.choose(node)">
{{node.id}}
</a>
</div>
</div>
</div>
</div>
</div>
NodeController.js
(function () {
'use strict';
angular.module('app.node', ['app.nodeService', 'app.nodeManager'])
.controller('NodeController', NodeController);
NodeController.$inject = ['nodeManager', '$log'];
function NodeController(nodeManager, $log) {
var vm = this;
//*************************************************************************
//* Populate the nodes initially
//*************************************************************************
nodeManager.getNode(0).then(function(node) {
vm.node = node;
});
//*************************************************************************
//* Actions to take when a node is selected from the list
//*************************************************************************
vm.choose = function(node) {
vm.node.selected = node;
$log.info('vm.choose called!');
$log.info('vm.node.selected');
$log.info(vm.node.selected);
};
}
})();