开通尝试

angular自定义标签

<!DOCTYPE html>
<html lang="en" ng-app='myApp'>
<head>
<meta charset="utf-8">
<script src="js/angular.min.js"></script>
<script>
var m1 = angular.module('myApp',[]);
m1.controller('Aaa',['$scope',function($scope){
$scope.name='hello';
}])
m1.directive('hi',function(){
return{
restrict:"AEC",
template:"<p>angularJs</p>",
replace:true
}
})
</script>
</head>
<body ng-controller='Aaa'>

<p>{{name}}</p>
<!-- <hi></hi> -->
<!-- <div hi></div> -->
<div class="hi"></div>
</body>
</html>

posted on 2017-05-23 11:33  有理想  阅读(96)  评论(0编辑  收藏  举报