angular.js icon indicating copy to clipboard operation
angular.js copied to clipboard

Similar directive parameters overwrite each other

Open myisis opened this issue 12 years ago • 2 comments

This example does not find dataGetter. I think it's due to the existence of attribute data (if I rename dataGetter to datasGetter it works).

mod.directive('blah', function() {
    return {
      restrict: 'E',
      template: '<div></div>',
      scope: {
        data: '=?',
        dataGetter: '&?'
      },
      controller: function ($scope, $element, $attrs) {
        var data = $scope.data || $scope.dataGetter();
        console.log(data);
      }
    }
  });
<blah data-getter='getData()'></blah>

Using AngularJS v1.2.13

myisis avatar Aug 11 '14 09:08 myisis

it's conflict with html5 data attribute https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Using_data_attributes

try to use:

<blah data-data-getter='getData()'></blah>

amitmtrn avatar Aug 11 '14 10:08 amitmtrn

@myisis this works as designed. A given directive can be referenced variety of prefix names, data- being one of them, you can find more info here: https://docs.angularjs.org/guide/directive in the "Matching Directives" section.

pkozlowski-opensource avatar Aug 11 '14 11:08 pkozlowski-opensource