<!DOCTYPE HTML>
<html ng-app="app">
<head>
<title>custom-directive</title>
<meta charset="utf-8">
<link rel="stylesheet" href="../css/bootstrap.css">
<script src="../js/angular.js"></script>
</head>
<body>
<!-- 下面是带嵌套的自定义指令demo. -->
<div>
<hello>Lucy</hello>
</div>
<script>
var myModule = angular.module("app",[]);
myModule.directive('hello',function(){
return {
restrict:'AE',
replace:true,
transclude:true,
template:'<div>Hi there <span ng-transclude></span></div>'
}
});//如果声明了模板,而html中还有嵌套内容的话,就必须用<span ng-transclude></span>指定其嵌套的位置,并声明transclude:true,这个属性为true,否则嵌套内容不会显示
</script>
</body>
</html>