<!DOCTYPE html>
<html ng-app="myModule">
<head>
<meta charset="utf-8">
</head>
<body>
<hello></hello>
</body>
<script src="https://cdn.bootcss.com/angular.js/1.4.6/angular.min.js"></script>
<script>
var myModule=angular.module("myModule",[]);
myModule.directive("hello",function(){
return {restrict:'E',template:'<div>hi</div>',replace:true}
});
</script>
</html>
指令
<!DOCTYPE html>
<html ng-app>
<head>
<meta charset="utf-8">
<script src="https://cdn.bootcss.com/angular.js/1.4.6/angular.min.js"></script>
</head>
<body>
<div>
<p>名字 : <input type="text" ng-model="name"></p>
<h1>Hello {{name}}</h1>
</div>
</body>
</html>
数据绑定