代码改变世界

16.简单的自定义指令

2017-04-13 17:29  笨笨03  阅读(154)  评论(0编辑  收藏  举报
<!DOCTYPE html>
<html ng-app="myApp" >
<head lang="en">
<meta charset="UTF-8">
<title>T2</title>
<script src="js/angular.js" type="text/javascript"></script>

</head>
<body>

<p class="run-directive"></p>


</body>

<script>
var app=angular.module("myApp",[]);
app.directive("runDirective", function () { //去掉横杠,d大写
return{
restrict:"C", //E:标签 A:属性 C:类别 M:注释
template:"<h1>自定义的指令!</h1>"
};
});



</script>
</html>