-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomponentizacao.html
36 lines (36 loc) · 1.41 KB
/
componentizacao.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<html xmlns="http://www.w3.org/1999/html">
<head>
<script src="angular.js"></script>
<link href="bootstrap.css" rel="stylesheet">
<script>
angular.module('myApp', [])
.directive('minhaDiretiva', function () {
return {
template: '<div>' +
'<p>Valor veio de atributo: {{valorViaAtributo}} </p>' +
'<p>Valor vindo de escopo: {{valorDoEscopo}}</p>' +
'</div>',
restrict: 'EA',
link: function (scope, element, attrs) {
element.bind('mouseenter', function () {
element.css('background', '#FF2213');
});
element.bind('mouseleave', function () {
element.css('background', '#AAAAAA');
})
},
scope: {
valorViaAtributo: '@valorViaAtributo',
valorDoEscopo: '=valorDoEscopo'
}
}
})
</script>
</head>
<body ng-app="myApp" ng-init="valor = 'Valor no Escopo'">
<div minha-diretiva
valor-via-atributo="Valor Via Atributo"
valor-do-escopo="valor">
</div>
</body>
</html>