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

<!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 作为注释使用

本文转自  素颜猪  51CTO博客,原文链接:http://blog.51cto.com/suyanzhu/1895268
上一篇:linux下的标准输出和错误输出重定向


下一篇:shell将标准错误输出重定向到 其他地方