AngularJS Example:
HTML
<div ng-app="app">
<my-foo ng-required="true"></my-foo>
</div>
CSS
</style> <!-- Ugly Hack due to jsFiddle issue: http://goo.gl/BUfGZ -->
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0-rc.1/angular.js"></script>
<script src="https://code.angularjs.org/1.4.0-rc.1/angular-animate.js"></script>
<style>
JavaScript
angular.module('app', ['ngAnimate'])
.directive('myFoo', function () {
return {
restrict: 'E',
scope: {
required: '=required'
},
template: '<p>Required: <span ng-bind="required"></span></p>',
link: function (scope, element, attrs, ctrl) {
}
};
});