发现这个可选参数就是闲的蛋疼!!!
不多说,看代码
可选参数:replace
默认为false,可以设置为true
若设置为true,dom中显示为:
<h3>Hello World</h3>
若设置为false
<ts-hello>
<h3>Hello World</h3>
</ts-hello>
<!DOCTYPE html>
<html ng-app='myApp'>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body ng-controller='firstCtrl'>
<ts-hello>
11
</ts-hello>
<script src='js/angular.js'></script>
<script>
var app = angular.module('myApp',['ng']);
app.controller('firstCtrl',['$scope',function($scope){
}]);
app.directive('tsHello',function(){
return {
template:'<h3>Hello World</h3>',
restrict:'ECAM',
replace:true
}
});
</script>
</body>
</html>