December 2014
Intermediate to advanced
272 pages
8h 17m
English
AngularJS makes it very simple to test HTML elements that are bound to the scope of the controller. This is because the values are stored in scope and can directly be referenced in the controller.
Consider a web page that has a single text <input> element that you have a back-end function to test, and verify that it is not empty and that it is fewer than 10 characters.
<body> Data: <input type="text" /></body>
The back-end code would look something like this:
function InputCtrl(){ var input = $('input'); var val = input.val(); this.verify = function(){ if (val.length > 0 $$ val.length < 10){ return true; } else { ...
Read now
Unlock full access