docs(all): convert <pre>/</pre> snippets to GFM snippets

This commit is contained in:
Caitlin Potter
2014-02-06 14:02:18 +00:00
committed by Peter Bacon Darwin
parent 2e641ac49f
commit f7d28cd377
54 changed files with 594 additions and 516 deletions

View File

@@ -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: