Q: Cannot change ng-model from inside directive I'm trying to create a directive which changes ng-model from a parent html tag but it is not working:
var app = angular.module('myApp',[]);
app.controller('ParentController',['$scope', function($scope) {
  $scope.anyVar = "Anything";

  $scope.list = ['It doesn\'t work','It also doesn\'t work'];

}]);

app.directive('customValue', [function() {
    return {
      restrict: 'A',
      require: '^?ngModel',
      link: function(scope, element, attr, ngModel) {
          element.bind('click',function() {
              var element = angular.element(this);
              ngModel.$setViewValue(element.attr('custom-value'));
          });

          scope.$watch(function(){
              return ngModel.$modelValue;
          }, function(modelValue){
              console.log("Wow, it was changed to : " + modelValue)  
          });
      }
    };
}]);

This is my view:
<div ng-app="myApp">
 <div ng-controller="ParentController">
       {{anyVar}}  
     <ul ng-model="anyVar">
       <li>
            <a custom-value="111">It' not working</a>
        </li>
        <li>
            <a custom-value="222">It's not working as well</a>
        </li>
        <li>
            ----------------------
        </li>
        <li ng-repeat="item in list">
            <a custom-value="333">{{item}}</a>
        </li>
     </ul>
 </div>
</div>

How can I update the parent ng-model from an inside directive with and without ng-repeat.
I have created a FIDDLE

A: Basically updating ng-model or any scope value from events will not run digest cycle, resultant the angular binding doesn't get updated on UI, you need to run it manually by doing scope.$apply(). This will run angular digest cycle and binding will update on Markup.
Code
$scope.$apply(function(){
   ngModel.$setViewValue(123);
});

Working Fiddle
