<html>
<head>
<meta charset="utf-8"/>
<title></title>
</head>
<body ng-app="components">
<myelement>
<h1>哈哈</h1>
</myelement>
</body>
<script src="angular.js"></script>
<script>
var app= angular.module(‘components‘, []);
app.directive(‘myelement‘, function() {
return {
restrict: ‘AE‘,//自定义属性和Dom节点
transclude: true,//将自定义指令内部原有的节点保留(这里注意,自定义指令中的内容在模板中必须有父节点)
scope: {},
templateUrl:"templates/templateOther.html",
replace: true//全部替换
};
});
</script>
</html>
原文:http://www.cnblogs.com/zzq-include/p/4491898.html