From f7d28cd377f06224247b950680517a187a7b6749 Mon Sep 17 00:00:00 2001 From: Caitlin Potter Date: Thu, 6 Feb 2014 14:02:18 +0000 Subject: docs(all): convert
/snippets to GFM snippets --- docs/content/tutorial/step_11.ngdoc | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'docs/content/tutorial/step_11.ngdoc') 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`.__ -
+ +```html ... ... -+``` ## Service __`app/js/services.js`.__ -
+
+```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}
});
}]);
-
+```
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`.__
-
+
+```js
...
angular.module('phonecatApp', ['ngRoute', 'phonecatControllers','phonecatFilters', 'phonecatServices']).
...
-
+```
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`.__
-
+
+```js
...
phonecatApp.controller('PhoneListCtrl', ['$scope', 'Phone', function($scope, Phone) {
@@ -92,7 +96,7 @@ phonecatApp.controller('PhoneDetailCtrl', ['$scope', '$routeParams', 'Phone', fu
$scope.mainImageUrl = imageUrl;
}
}]);
-
+```
Notice how in `PhoneListCtrl` we replaced:
@@ -133,7 +137,8 @@ ignores methods.
__`test/unit/controllersSpec.js`:__
-
+
+```js
describe('PhoneCat controllers', function() {
beforeEach(function(){
@@ -204,7 +209,7 @@ describe('PhoneCat controllers', function() {
});
});
});
-
+```
You should now see the following output in the Karma tab:
--
cgit v1.2.3