minhas-diretivas.js
angular.module("minhasDiretivas", [])
.directive("meuPainel", function(){
var ddo = {
restrict: "AE",
scope: {
titulo: "@"
},
transclude: true,
templateUrl: "/js/directives/meu-painel.html"
};
return ddo;
});
index.html
<!DOCTYPE html>
<html lang="pt-br" ng-app="alurapic">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<title>Alurapic</title>
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/bootstrap-theme.min.css">
<script src="js/lib/angular.min.js"></script>
<script src="js/main.js"></script>
<script src="js/controllers/fotos-controller.js"></script>
<script src="js/directives/minhas-diretivas.js"></script>
</head>
<body ng-controller="FotosController">
<div class="container">
<div class="jumbotron">
<h1 class="text-center">Alurapic</h1>
</div>
<div class="row">
<meu-painel ng-repeat="foto in fotos" titulo="{{foto.titulo}}">
<img class="img-responsive center-block" src="{{foto.url}}" alt="{{foto.titulo}}">
</meu-painel>
</div><!-- fim row -->
</div><!-- fim container -->
</body>
</html>
main.js
angular.module('alurapic', ['minhasDiretivas']);
meu-painel.html
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title text-center">{{titulo}}</h3>
</div>
<div class="panel-body" ng-transclude>
</div>
</div>