Popover doesn't update on scope variable change


I want to add an “activated” css class to a popover item with ng-class depending on a scope variable. The idea is that the popover would display a list of options and the currently set option would be activated. But if the scope variable is changed in the controller the popover doesn’t reflect the change when it’s opened again. I put togeher a codepen of the problem. In the real project i initially load the value from localstorage and the item in the popover is activated properly on the first open, but then if the value is changed it doesn’t work either. Also, I there’s no way to use $scope.$apply() because if I add it in the end of the item click handler, an error happens, saying “$scope.$apply() is already in progress”