angular.js
angular.js copied to clipboard
Similar directive parameters overwrite each other
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
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>
@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.