您的位置:首页 > 其它

限制你的指令只能通过特定的方式来调用

2017-02-06 14:12 225 查看
<!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:"<h1>只能通过属性的方式来调用</h1>"
}
});
</script>
</html>
说明:
restrict 值可以是以下几种:
E
作为元素名使用

A
作为属性使用

C
作为类名使用

M
作为注释使用
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  限制 指令 只能通过