angular 1.x directive
emer 发布于 2017-9-26 22:02 2035 次阅读
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <script src="angular.min.js"></script> </head> <body ng-app="myapp" > <div id="box" > <input type="text" ng-model="msg"> {{msg}} <li myshu="">1</li> <li>2</li> <li>3</li> <li>4</li> <li>5</li> </div> <script> var app=angular.module("myapp",[]); app.controller("boa",function($scope){ $scope.msg="你好"; }) app.directive("myshu",function(){ var json={ restict:"A", template:"<ng-transclude></ng-transclude><a href='javasctipt:;'>X</a>", transclude:true } return json; }) </script> </body> </html>