Why angular {{}} syntax prevent the change from attrs.$set in directive?

Viewed 76

When apply angular syntax {{}} on element, directive attrs.$set will not work.

Edit: My question is could anyone explain why?

If {{}} parsed and then link, why wouldn't the element been modified by link?

If link first, {{}} should be removed, both condition will not result like this.

Here is the code pen

<div ng-app="ngApp" ng-controller="global">
  <a aaa href="http://{{::lan}}/4567">has syntax</a>
  <a aaa href="http://nosyntax/4567">no syntax</a>
</div>

angular.module('ngApp',[])
  .directive('aaa',function(){
  return {
    link:function(scope, ele, attr){
      attr.$set('href','http://fromdirective');
    }
  }
}).controller('global',function($scope){
  $scope.lan = 'en-gb';
})
3 Answers
Related