On t of its plunger, you may notice strange behavior with the data-* attribute name template in the directive.
Call:
<body ng-app="apptest" ng-controller="Controller"> Test of data named attribute : <br/> <directivetest data-test="vartest" test="vartest" another-test="vartest"></directivetest> </body>
directives:
angular.module('apptest', []) .controller('Controller', ['$scope', function($scope) { $scope.vartest = "This is a test"; } ]) .directive('directivetest', function() { return { restrict: 'E', scope: { dataTest: '=', test: '=', anotherTest: '=' }, templateUrl: "directive.html" } });
will take into account all directivetest attributes, but data-test and therefore will display:
Test of data named attribute : Attribute with data-* name : Attribute with regular name : This is a test Attribute with an other regular name : This is a test
I wonder why this is happening (I spent 4 hours before I realized that this is a problem).
It seems impossible to name the data-* directive, why is this?
I read something about it here http://www.w3schools.com/tags/att_global_data.asp , why is my attribute undefined? Is it just not readable by the browser?
javascript angularjs html5
Valentin cavel
source share