Angular: Empty Fiddle
http://angularjs.org/
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.1/angular.min.js"></script>
<div ng-controller="MyCtrl as ctrl">
Hello, <span simple-directive ctrl="ctrl"></span>!
<br />
<input type="text" ng-model="ctrl.name">
</div>
JavaScript
var myApp = angular.module('myApp',[]);
myApp.controller('MyCtrl', function ($scope) {
this.name = 'Superhero';
});
myApp.directive('simpleDirective', function () {
return {
restrict: 'A',
scope: {
ctrl: '='
},
template: '{{ ctrl.name }}',
link: function (scope, elem, attrs) {
}
}
});