菜单切换
FACESOHO知行者
心灵
记录
远方
赞赏工具
源代码:
点击运行
保存
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <script src="https://cdn.staticfile.org/angular.js/1.4.6/angular.min.js"></script> </head> <body ng-app="myApp"> <div class="facesoho-directive"></div> <script> var app = angular.module("myApp", []); app.directive("facesohoDirective", function() { return { restrict :"C", template :"<h1>自定义指令!</h1>" }; }); </script> <p><strong>注意:</strong> 你必须设置 <b>restrict</b> 的值为 "C" 才能通过类名来调用指令。</p> </body> </html>
运行结果