0
点赞
收藏
分享

微信扫一扫

angular34-自定义指令2

<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>

<body ng-app="myApp1">
<btn primary="true" lg block></btn>
<script src="./js/Angular.js"></script>
<script>
var myApp1 = angular.module('myApp1', []);
//第一个参数是指令的名字 第二个参数应该使用一个数组
//数组的最后一个元素是一个函数
myApp1.directive('btn', [function() {
return {
scope: {
primary: '@',
lg: '@',
block: '@'
},
//指令对象的属性
transclude: true,
template: '<button class="btn{{primary?\'btn-primary\':\'\'}}">button</button>'
}
}])
</script>
</body>

</html>

运行结果

angular34-自定义指令2_html

 

举报

相关推荐

0 条评论