The scope attributes of a directive break depending on the attribute name

I have a very strange phenomenon with a directive and an isolated area where attributes in the area work or not work depending on the name of the attribute. If i use

{check:'@check'}

It works fine and as expected. However, if I use:

{checkN:'@checkN'}

a specific function is never assigned. An example would look like this:

HTML:

<item ng-repeat="list_item in model.list" model="list_item" checkN="checkName()" check="checkName()" position="$index"></item>'

Javascript

app.directive('item', function(){
   return {
      restrict: 'E',
      replace : false,   
      scope:{
              $index: '=position',
              check: '&check',
              checkN: '&checkN',
              model:'='
      },          
      template: '',
      link: function(scope, element, attrs){
        console.log(scope.check())
        console.log(scope.checkN())          
      }
    }
});

Then the console will give me the following:

The checkName function has been called [which is the return string of the function]
undefined

Is it entirely possible that this depends on the use of capital letters? This would be a very "unexpected" behavior.

thanks for the help

schacki

+5
source share
1 answer

Html , myAttribute myAttribute . Angularjs html javascript .

ngRepeat ng-repeat (html). , checkN check-n angular, .

+9

All Articles