<!DOCTYPE html>
<html ng-app="app">

  <head>
    <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.19/angular.js"></script>
    <script src="script.js"></script>
  </head>

  <body ng-controller="PruebaController">
    <ac-titulo texto="Hola Mundo" color="rojo" ></ac-titulo>
  </body>

</html>
var app = angular.module("app",[]);

app.directive("acTitulo",[function() {
  
  var directiveDefinitionObject ={
    restrict:"E",
    replace : true,
    template:"<h1>{{texto}}</h1>",
    scope:{
      texto:"@"
    },
    link:function(scope, iElement, iAttrs, controller, transcludeFn) {
        var htmlColor;
        
        switch (iAttrs.color) {
            case "rojo":
                htmlColor="#FF0000";
                break;
            case "verde":
                htmlColor="#00FF00";
                break;
            case "azul":
                htmlColor="#0000FF";
                break;
            default:
                htmlColor="#000000";
                break;
        }
      
        iElement.css("color",htmlColor);
      
    }
    
  }
  
  return directiveDefinitionObject;
}]);



app.controller("PruebaController", function($scope) {
  
});
Ejemplo de funciĆ³n link de una directiva