AngularJS Example

HTML

<div ng-app="helloHabrahabr">
  <div ng-controller="forExampleController">
    <input ng-model="word">
    <span habra-habr="word" habra="Nehabra"></span>
  </div>
</div>

JavaScript

function forExampleController($scope) {
    $scope.word="Habrahabra"
}

angular.module('helloHabrahabr', [])
    .directive('habraHabr', function() {
        return {
            link:function($scope, element, attrs) {
                /*Задаем функцию, которая будет вызываться при изменении переменной word*/
                $scope.$watch(attrs.habraHabr,function(value){
                        element.text(value+attrs.habra);
                    }
                );
            }
        }
    });