Hello,
I looked at Your stackoverflow question - I don't understand why You wrote the controller the way You did. Also: are You sure as far as the logic of Your application goes that You need to use a controller? You count badges in the controller, You might as well do that inside the directive.