标签:rac 默认 turn doc ast r.js html set function
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script src="http://cdn.static.runoob.com/libs/angular.js/1.4.6/angular.min.js"></script> </head> <body ng-app="myApp" ng-init="obj={ a:1,b:2,firstName:‘guanghan‘,lastName:‘xue‘}"> <div > <div class="runoob-directive"></div> </div> <script> var app = angular.module("myApp", []); app.directive("runoobDirective", function () { return { restrict: ‘C‘,//表示使用class匹配 默认使用标签匹配 即 <runoob-directive></runoob-directive> template: "<h1>自定义指令!</h1>"//这是对应得输出html模板 }; }); </script> </body> </html>
也可以这样使用
<div runoob-directive></div> 使用属性匹配restrict不要填就行了
标签:rac 默认 turn doc ast r.js html set function
原文地址:http://www.cnblogs.com/ProDoctor/p/7064145.html