From 075c089b5cbe72e95ec96638f8925aeb44824f7c Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Fri, 27 Apr 2012 15:18:54 -0700 Subject: docs(tutorial): update all the remaining steps I made some diagrams and portions of the text that are stil stale invisible. We'll fix these in the next relese. --- docs/content/tutorial/step_08.ngdoc | 61 +++++++++++++++++++++---------------- 1 file changed, 35 insertions(+), 26 deletions(-) (limited to 'docs/content/tutorial/step_08.ngdoc') diff --git a/docs/content/tutorial/step_08.ngdoc b/docs/content/tutorial/step_08.ngdoc index ad206452..9ccaf9b4 100644 --- a/docs/content/tutorial/step_08.ngdoc +++ b/docs/content/tutorial/step_08.ngdoc @@ -2,8 +2,6 @@ @name Tutorial: 8 - More Templating @description -
-function PhoneDetailCtrl($xhr) {
- var self = this;
-
- $xhr('GET', 'phones/' + self.params.phoneId + '.json', function(code, response) {
- self.phone = response;
+function PhoneDetailCtrl($scope, $routeParams, $http) {
+ $http.get('phones/' + $routeParams.phoneId + '.json').success(function(data) {
+ $scope.phone = data;
});
}
-//PhoneDetailCtrl.$inject = ['$xhr'];
+//PhoneDetailCtrl.$inject = ['$scope', '$routeParams', '$http'];
-To construct the URL for the HTTP request, we use `params.phoneId` extracted from the current route
-in the `PhoneCatCtrl` controller.
+To construct the URL for the HTTP request, we use `$routeParams.phoneId` extracted from the current
+route by the `$route` service.
## Template
The TBD placeholder line has been replaced with lists and bindings that comprise the phone details.
-Note where we use the angular `{{expression}}` markup and `ng:repeater`s to project phone data from
+Note where we use the angular `{{expression}}` markup and `ngRepeater`s to project phone data from
our model into the view.
__`app/partials/phone-details.html`:__
-+
![]()
{{phone.name}}
{{phone.description}}
...
- it('should fetch phone detail', function() {
- scope.params = {phoneId:'xyz'};
- $browser.xhr.expectGET('phones/xyz.json').respond({name:'phone xyz'});
- ctrl = scope.$new(PhoneDetailCtrl);
+ describe('PhoneDetailCtrl', function(){
+ var scope, $httpBackend, ctrl;
+
+ beforeEach(inject(function(_$httpBackend_, $rootScope, $routeParams, $controller) {
+ $httpBackend = _$httpBackend_;
+ $httpBackend.expectGET('phones/xyz.json').respond({name:'phone xyz'});
- expect(ctrl.phone).toBeUndefined();
- $browser.xhr.flush();
+ $routeParams.phoneId = 'xyz';
+ scope = $rootScope.$new();
+ ctrl = $controller(PhoneDetailCtrl, {$scope: scope});
+ }));
- expect(ctrl.phone).toEqual({name:'phone xyz'});
+
+ it('should fetch phone detail', function() {
+ expect(scope.phone).toBeUndefined();
+ $httpBackend.flush();
+
+ expect(scope.phone).toEqual({name:'phone xyz'});
});
+ });
...
@@ -144,7 +153,7 @@ output.
Chrome: Runner reset.
...
Total 3 tests (Passed: 3; Fails: 0; Errors: 0) (5.00 ms)
- Chrome 11.0.696.57 Mac OS: Run 3 tests (Passed: 3; Fails: 0; Errors 0) (5.00 ms)
+ Chrome 19.0.1084.36 Mac OS: Run 3 tests (Passed: 3; Fails: 0; Errors 0) (5.00 ms)
We also added a new end-to-end test that navigates to the Nexus S detail page and verifies that the
--
cgit v1.2.3