Text directives

Overview

An able to control a declarative data binding in the HTML

example how to use text directives
<div al-app>
    counter {{#counter}}
</div>
text directive counter
 alight.text.counter = function(callback, expression, cd) {
     var n = 0;
     setInterval(function(){
         n++;
         callback(n)     // set result
         cd.scan()       // $digest
     }, 1000);
 }

Input arguments

  • callback - a function to set a value
  • expression - expression of directive
  • cd - change detector
  • env. finally - a function to set the final value, after that $watch will be removed.
  • env.**setter** = callback

Examples

comments powered by Disqus