I'm just starting out with AngularJS and struggling to find the answer to my question. I really want to refactor my app in an MVC way before it turns into a tangled mess :)
Currently, I have a directive that shows the number of users in groups who are currently logged in. Here is an example:
angular.module('dashboard').directive('indicator',
function($scope) {
var directive = {
restrict: 'E',
scope: { free: '=' },
template: '<div><h3>Free<h3><span>{{free}}</span></div>'
};
return directive;
});
This number updates instantly when there is a change (using SignalR). The JSON response from the server looks like this:
{
groupId: 123,
loggedIn: 12,
onPause: 2,
total: 20
}
My goal is to locate the directive that displays data for a specific group ID and update its scope object accordingly. What would be the best approach to achieve this?