Controller as in Angular 1.2

Demonstrates usage of controller as in a view, in a route and in a directive

HTML

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.1/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.1/angular-route.min.js"></script>
<div ng-app="myapp">                           
    0
    <check-directive line="...">
        a{{line}}b{{newLine}}c
    </check-directive>
    1
</div>

JavaScript

var module = angular.module('myapp', []);

module.directive('checkDirective', function() {
  return {
    restrict: 'E',
    scope: { line: '@' },
    transclude: true,
    controller: function($scope) {
        $scope.newLine = $scope.line;
    },
      link: function (scope, elem, attrs, ctrl, transcludeFn) {
          transcludeFn(scope, function (clone, scope) {
              elem.append(clone);
          });
      },
  };
});