From 073e76f8353ca3f743ea61ff21f7de7b1e5a7701 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Thu, 24 May 2012 15:29:51 -0700 Subject: doc(guide): corrected examples --- docs/content/guide/compiler.ngdoc | 70 ++++++++++++++--------------- docs/content/guide/overview.ngdoc | 24 +++++----- docs/content/guide/scope.ngdoc | 94 +++++++++++++++++++-------------------- 3 files changed, 94 insertions(+), 94 deletions(-) (limited to 'docs/content/guide') diff --git a/docs/content/guide/compiler.ngdoc b/docs/content/guide/compiler.ngdoc index d854ea37..493b611f 100644 --- a/docs/content/guide/compiler.ngdoc +++ b/docs/content/guide/compiler.ngdoc @@ -66,45 +66,45 @@ to write directives. Here is a directive which makes any element draggable. Notice the `draggable` attribute on the `` element. - - - + + function mouseup() { + $document.unbind('mousemove', mousemove); + $document.unbind('mouseup', mouseup); + } + } + }); + + Drag ME - - + + The presence of `draggable` attribute an any element gives the element new behavior. The beauty of diff --git a/docs/content/guide/overview.ngdoc b/docs/content/guide/overview.ngdoc index afd314b7..71eb90e9 100644 --- a/docs/content/guide/overview.ngdoc +++ b/docs/content/guide/overview.ngdoc @@ -75,14 +75,14 @@ concepts which the application developer may face: * computing new values based on the model. * formatting output in a user specific locale. - - - + + + function InvoiceCntl($scope) { + $scope.qty = 1; + $scope.cost = 19.95; + } + +
Invoice:
@@ -97,16 +97,16 @@ concepts which the application developer may face:
Total: {{qty * cost | currency}}
-
- + + it('should show of angular binding', function() { expect(binding('qty * cost')).toEqual('$19.95'); input('qty').enter('2'); input('cost').enter('5.00'); expect(binding('qty * cost')).toEqual('$10.00'); }); - -
+ + Try out the Live Preview above, and then let's walk through the example and describe what's going on. diff --git a/docs/content/guide/scope.ngdoc b/docs/content/guide/scope.ngdoc index 4d104b8c..dac69d8a 100644 --- a/docs/content/guide/scope.ngdoc +++ b/docs/content/guide/scope.ngdoc @@ -38,17 +38,17 @@ arrangement isolates the controller from the directive as well as from DOM. This point since it makes the controllers view agnostic, which greatly improves the testing story of the applications. - - - + + + function MyController($scope) { + $scope.username = 'World'; + + $scope.sayHello = function() { + $scope.greeting = 'Hello ' + $scope.username + '!'; + }; + } + +
Your name: @@ -56,8 +56,8 @@ the applications.
{{greeting}}
-
-
+ + In the above example notice that the `MyController` assigns `World` to the `username` property of the scope. The scope then notifies the `input` of the assignment, which then renders the input @@ -117,26 +117,26 @@ inheritance, and child scopes prototypically inherit from their parents. This example illustrates scopes in application, and prototypical inheritance of properties. - - - - + + + /* remove .doc-example-live in jsfiddle */ + .doc-example-live .ng-scope { + border: 1px dashed red; + } + + + function EmployeeController($scope) { + $scope.department = 'Engineering'; + $scope.employee = { + name: 'Joe the Manager', + reports: [ + {name: 'John Smith'}, + {name: 'Mary Run'} + ] + }; + } + +
Manager: {{employee.name}} [ {{department}} ]
Reports: @@ -148,8 +148,8 @@ This example illustrates scopes in application, and prototypical inheritance of
{{greeting}}
-
-
+ + Notice that the Angular automatically places `ng-scope` class on elements where scopes are attached. The `