angular 1.x directive

Others 2017-09-26 14:02:00 2017-09-26 14:02:00 2056 次浏览
<!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>