我有两件事要做:
var app=angular.module('app.directives', []);
app.directive('dropdowns', function() {alert("dropdown directive"); return { restrict: 'AE', templateUrl: 'html/uploadFile.html' }; }); app.directive('uploadDir', function() { alert("upload directive"); return { restrict : 'AE', templateUrl : 'html/dropdowns.html' }; });
下拉指令正在运行 但上传指令不起作用(uploadDir指令中的警告消息未显示)
语法是否正确?
的index.html
<!DOCTYPE html>
<html ng-app="app">
<head>
<meta charset="ISO-8859-1">
<title>upload using directive</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<script type="text/javascript" src="lib/ui-bootstrap-tpls-0.13.0.js"></script>
<link type="text/css" rel="stylesheet" href="css/bootstrap.min.css"/>
<script type="text/javascript" src="js/app.js"></script>
<script type="text/javascript" src="js/controllers/controllers.js"></script>
<script type="text/javascript" src="js/services/services.js"></script>
<script type="text/javascript" src="js/directives/directives.js"></script>
</head>
<body>
<div>
<div dropdowns></div>
<div uploadDir></div>
</div>
</body>
</html>
答案 0 :(得分:5)
使用<div upload-dir></div>
。在匹配HTML元素时,使用破折号对驼峰式情况下的指令名称进行规范化。