Val*_*vel 8 javascript html5 angularjs
在他的plunker你可以注意到一个奇怪的行为与data-*指令中的属性名称的模式.
电话:
<body ng-app="apptest" ng-controller="Controller">
Test of data named attribute :
<br/>
<directivetest data-test="vartest" test="vartest" another-test="vartest"></directivetest>
</body>
Run Code Online (Sandbox Code Playgroud)
指令:
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"
}
});
Run Code Online (Sandbox Code Playgroud)
将考虑所有属性,directivetest但data-test因此显示:
Run Code Online (Sandbox Code Playgroud)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
我想知道为什么会发生这种情况(我浪费了4个小时才发现这是问题所在).
命名指令似乎是不可能的data-*,为什么呢?
我在这里阅读了一些关于它的内容http://www.w3schools.com/tags/att_global_data.asp,这是为什么我的属性未定义?浏览器根本无法读取它?
| 归档时间: |
|
| 查看次数: |
3114 次 |
| 最近记录: |