-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinjecao-dependencia-com-modulo.html
30 lines (30 loc) · 1.27 KB
/
injecao-dependencia-com-modulo.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
<html xmlns="http://www.w3.org/1999/html">
<head>
<script src="angular.js"></script>
<link href="bootstrap.css" rel="stylesheet">
<script>
angular.module('myAppSemDependencia', []).directive('minhaDiretiva', function() {
return {
template: '<div>{{valorViaAtributo}} {{valorDoEscopo}}</div>',
restrict: 'A',
link: function(scope, element, attrs) {
element.bind('mouseenter', function() {
element.css('background', '#FFCC29');
});
element.bind('mouseleave', function() {
element.css('background', '#00A859');
})
},
scope: {
valorViaAtributo: '@valorViaAtributo',
valorDoEscopo: '=valorDoEscopo'
}
}
})
angular.module('myAppComDependencia', ['myAppSemDependencia'] );
</script>
</head>
<body ng-app="myAppComDependencia" ng-init="valor = 'Valor no Escopo'" >
<div minha-diretiva valor-via-atributo="Valor Via Atributo" valor-do-escopo="valor" ></div>
</body>
</html>