diff options
Diffstat (limited to 'docs/content/tutorial/step_09.ngdoc')
| -rw-r--r-- | docs/content/tutorial/step_09.ngdoc | 25 | 
1 files changed, 15 insertions, 10 deletions
| diff --git a/docs/content/tutorial/step_09.ngdoc b/docs/content/tutorial/step_09.ngdoc index 8d23af3e..0e32001d 100644 --- a/docs/content/tutorial/step_09.ngdoc +++ b/docs/content/tutorial/step_09.ngdoc @@ -26,13 +26,14 @@ In order to create a new filter, you are going to create a `phonecatFilters` mod  your custom filter with this module:  __`app/js/filters.js`:__ -<pre> + +```js  angular.module('phonecatFilters', []).filter('checkmark', function() {    return function(input) {      return input ? '\u2713' : '\u2718';    };  }); -</pre> +```  The name of our filter is "checkmark". The `input` evaluates to either `true` or `false`, and we  return one of the two unicode characters we have chosen to represent true (`\u2713` -> ✓) or false (`\u2718` -> ✘). @@ -41,11 +42,12 @@ Now that our filter is ready, we need to register the `phonecatFilters` module a  our main `phonecat` module.  __`app/js/app.js`:__ -<pre> + +```js  ...  angular.module('phonecatApp', ['phonecatFilters']).  ... -</pre> +```  ## Template @@ -54,12 +56,13 @@ Since the filter code lives in the `app/js/filters.js` file, we need to include  layout template.  __`app/index.html`:__ -<pre> + +```html  ...   <script src="js/controllers.js"></script>   <script src="js/filters.js"></script>  ... -</pre> +```  The syntax for using filters in Angular templates is as follows: @@ -70,7 +73,8 @@ Let's employ the filter in the phone details template:  __`app/partials/phone-detail.html`:__ -<pre> + +```html  ...      <dl>        <dt>Infrared</dt> @@ -79,7 +83,7 @@ __`app/partials/phone-detail.html`:__        <dd>{{phone.connectivity.gps | checkmark}}</dd>      </dl>  ... -</pre> +```  ## Test @@ -87,7 +91,8 @@ __`app/partials/phone-detail.html`:__  Filters, like any other component, should be tested and these tests are very easy to write.  __`test/unit/filtersSpec.js`:__ -<pre> + +```js  describe('filter', function() {    beforeEach(module('phonecatFilters')); @@ -101,7 +106,7 @@ describe('filter', function() {      }));    });  }); -</pre> +```  We must call `beforeEach(module('phonecatFilters'))` before any of  our filter tests execute. This call loads our `phonecatFilters` module into the injector | 
