限制你的指令只能通过特定的方式来调用
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title></title>
<link rel="stylesheet" href="">
</head>
<body ng-app="myApp">
<div runoob-directive></div>
</body>
<script src="http://cdn.static.runoob.com/libs/angular.js/1.4.6/angular.min.js"></script>
<script>
var app = angular.module("myApp",[]);
app.directive("runoobDirective",function(){
return {
restrict:"A",
template:"<h2>只能通过属性的方式来调用</h2>"
}
});
</script>
</html>
说明:
restrict值可以是以下几种:
E
作为元素名使用
A
作为属性使用
C
作为类名使用
M
作为注释使用
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。