i have started to study Angular just a little time. I am trying to write an example of Custome Directive with TemplateURL. The problem is that in the new custom tag it's not print the result of the template.
To this link you can see the code.
Index.html
<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="it-IT">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Hello Angular</title>
<script src="../../angular.min.js"></script>
<script type="text/javascript" src="script.js"></script>
</head>
<body ng-app="myApp" ng-controller="controApp as ctrl">
<table border=2>
<thead>
<td>AAA</td>
<td>BBB</td>
<td>CCC</td>
</thead>
<tbody>
<lista-clienti lista="ctrl.elencoClienti"></lista-clienti>
</tbody>
</table>
</body>
</html>
script.js
var app = angular.module("myApp", []);
app.directive("listaClienti", function() {
return {
scope: {
lista : "="
},
//template: "<div>missing tpl</div>"
templateURL: "selectCity.html"
};
});
app.controller('controApp', function($scope ){
$scope.elencoClienti = [
{codiceCliente: "1", ragioneSociale: "Michele Srl", indirizzo_so:"Via delle calende greche" },
{codiceCliente: "2", ragioneSociale: "Michele Srl", indirizzo_so:"Via delle calende greche" },
];
});
selectCity.html
<tr ng-repeat="c in lista">
<td>{{c.codiceCliente}}</td>
<td>{{c.ragioneSociale}}</td>
<td>{{c.indirizzo_so}}</td>
</tr>
what could is the problem? Thanks
Directory Structure:
05_Custom_Directive
-- Example_02
----index.html
----script.js
----selectCity.html
<tr ng-repeat="c in lista"> <td>{{c.codiceCliente}}</td> <td>{{c.ragioneSociale}}</td> <td>{{c.indirizzo_so}}</td> </tr> this i a testThis will tell us if your template is getting injected or not../selectCity.html