The correct way is to have all your javascript in JS files, which essentially means controllers, services etc. Not in HTML.
You have one $scope.state variable, and use that to be display the status of all sections. So the result you get is what exactly you wrote in your program :).
If you want each section to maintain their states separately, you can include the state property in sections object as follows,
sections = {"data": [{
"label": "somelabel 1", state:'on'
},{
"label": "somelabel 2", state:'off'
}]};
In the do_this(), take the $index and set the state of the section,
$scope.do_this = function(index){
var section = sections.data[index];
if (section.state == 'off') {
dosomething();
section.state = 'on';
} else {
dosomethingElse();
section.state = 'on';
}
}
In your html you will need to pass the index for do_this
<a href="" ng-click="do_this($index)" data-state="{{!state}}" >{{!data.label}}</a>
Info on ngRepeat and $index