Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1891 | grupo3 | 1 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> |
2 | |||
3 | <p>Modulo Incluido contem as directivas e os templates necessários</p> |
||
4 | <p>Este módulo conhece o nome do módulo da App onde vai ser incluido</p> |
||
5 | |||
6 | <script> |
||
7 | angular.module("demoApp").directive('tpl', function() { |
||
8 | var contentUrl; |
||
9 | return { |
||
10 | restrict: 'E', //A ou E define se é o nome do elemento ou um atributo |
||
11 | link: function(scope, element, attrs) { |
||
12 | // concatenating the directory to the ver attr to select the correct excerpt for the day |
||
13 | //contentUrl = attrs.templatename + '.html'; |
||
14 | |||
15 | //console.log(contentUrl); |
||
16 | |||
17 | scope.teste = "teste"; |
||
18 | scope.move = function(){ |
||
19 | |||
20 | scope.teste = "teste2modules"; |
||
21 | //scope.testeSuper = "testeSuper2modules"; |
||
22 | angular.element("#demoApp").scope().testeSuper = "testeSuper2modules"; |
||
23 | } |
||
24 | scope.mudaCompName = function(comp){ |
||
25 | |||
26 | comp.name = "NOVO NOME DO COMP MUDADO NA DIRECTIVA"; |
||
27 | } |
||
28 | }, |
||
29 | // passing in contentUrl variable |
||
30 | templateUrl: function(elem,attrs) { |
||
31 | return "templateDirectiva"; |
||
32 | } |
||
33 | } |
||
34 | }); |
||
35 | </script> |
||
36 | |||
37 | <script type="text/ng-template" id="directive_class"> |
||
38 | <div style="border: 1px solid #000000"> |
||
39 | <h1>DIRECTIVE CLASS TEMPLATE</h1> |
||
40 | <p>COMP ELEMENTO DIRECTIVA:{{comp.name}}</p> |
||
41 | <p><input type="text" ng-model="comp.name"></p> |
||
42 | <tpl></tpl> |
||
43 | <p>Teste no scope da directiva<p> |
||
44 | <pre> |
||
45 | {{teste | json}} |
||
46 | </pre> |
||
47 | </div> |
||
48 | </script> |
||
49 | |||
50 | <script type="text/ng-template" id="templateDirectiva"> |
||
51 | <div style="border: 1px solid green"> |
||
52 | <h1>templateDirectiva</h1> |
||
53 | <p>TESTE</p> |
||
54 | <p>{{teste}}</p> |
||
55 | <p>{{testeSuper}}</p> |
||
56 | <p>COMP ELEMENTO DIRECTIVA:{{comp.name}}</p> |
||
57 | <button ng-click="move()">Muda Textos</button> |
||
58 | <button ng-click="mudaCompName(comp)">Muda COMP NAME</button> |
||
59 | </div> |
||
60 | </script> |