diff options
| author | Caitlin Potter | 2014-02-06 14:02:18 +0000 |
|---|---|---|
| committer | Peter Bacon Darwin | 2014-02-16 19:03:40 +0000 |
| commit | f7d28cd377f06224247b950680517a187a7b6749 (patch) | |
| tree | 20203b9f7bf60748bb752f325b1869415352a6f3 /docs/content/tutorial/step_11.ngdoc | |
| parent | 2e641ac49f121a6e2cc70bd3879930b44a8a7710 (diff) | |
| download | angular.js-f7d28cd377f06224247b950680517a187a7b6749.tar.bz2 | |
docs(all): convert <pre>/</pre> snippets to GFM snippets
Diffstat (limited to 'docs/content/tutorial/step_11.ngdoc')
| -rw-r--r-- | docs/content/tutorial/step_11.ngdoc | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/docs/content/tutorial/step_11.ngdoc b/docs/content/tutorial/step_11.ngdoc index ffd342ed..b3308cc6 100644 --- a/docs/content/tutorial/step_11.ngdoc +++ b/docs/content/tutorial/step_11.ngdoc @@ -25,17 +25,19 @@ template. Additionally, we also need to load the `angular-resource.js` file, whi `ngResource` module and in it the `$resource` service, that we'll soon use: __`app/index.html`.__ -<pre> + +```html ... <script src="js/services.js"></script> <script src="lib/angular/angular-resource.js"></script> ... -</pre> +``` ## Service __`app/js/services.js`.__ -<pre> + +```js var phonecatServices = angular.module('phonecatServices', ['ngResource']); phonecatServices.factory('Phone', ['$resource', @@ -44,7 +46,7 @@ phonecatServices.factory('Phone', ['$resource', query: {method:'GET', params:{phoneId:'phones'}, isArray:true} }); }]); -</pre> +``` We used the module API to register a custom service using a factory function. We passed in the name of the service - 'Phone' - and the factory function. The factory function is similar to a @@ -57,11 +59,12 @@ lines of code. This client can then be used in our application, instead of the l api/ng.$http $http} service. __`app/js/app.js`.__ -<pre> + +```js ... angular.module('phonecatApp', ['ngRoute', 'phonecatControllers','phonecatFilters', 'phonecatServices']). ... -</pre> +``` We need to add the 'phonecatServices' module dependency to 'phonecatApp' module's requires array. @@ -75,7 +78,8 @@ use than `$http` for interacting with data sources exposed as RESTful resources. now to understand what the code in our controllers is doing. __`app/js/controllers.js`.__ -<pre> + +```js ... phonecatApp.controller('PhoneListCtrl', ['$scope', 'Phone', function($scope, Phone) { @@ -92,7 +96,7 @@ phonecatApp.controller('PhoneDetailCtrl', ['$scope', '$routeParams', 'Phone', fu $scope.mainImageUrl = imageUrl; } }]); -</pre> +``` Notice how in `PhoneListCtrl` we replaced: @@ -133,7 +137,8 @@ ignores methods. __`test/unit/controllersSpec.js`:__ -<pre> + +```js describe('PhoneCat controllers', function() { beforeEach(function(){ @@ -204,7 +209,7 @@ describe('PhoneCat controllers', function() { }); }); }); -</pre> +``` You should now see the following output in the Karma tab: |
