Skip to content

Commit 245b60d

Browse files
committed
addded cookbook
1 parent b6a01bd commit 245b60d

16 files changed

Lines changed: 426 additions & 24 deletions

docs/cookbook.buzz.ngdoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
@workInProgress
2+
@ngdoc overview
3+
@name Cookbook: Resources - Buzz Demo
4+
@description

docs/cookbook.deeplinking.ngdoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
@workInProgress
2+
@ngdoc overview
3+
@name Cookbook: Deep Linking
4+
@description

docs/cookbook.form.ngdoc

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
@workInProgress
2+
@ngdoc overview
3+
@name Cookbook: Form
4+
@description
5+
6+
A web application's main purpose is to present and gather data. For this reason <angular/> strives to make both of these operations trivial. This example shows off how you can build a simple form to allow a user to enter data.
7+
8+
9+
<doc:example>
10+
<doc:source>
11+
<script>
12+
function FormController(){
13+
this.user = {
14+
name: 'John Smith',
15+
address:{line1: '123 Main St.', city:'Anytown', state:'AA', zip:'12345'},
16+
contacts:[{type:'phone', value:'1(234) 555-1212'}]
17+
};
18+
this.state = /^\w\w$/;
19+
this.zip = /^\d\d\d\d\d$/;
20+
}
21+
</script>
22+
<div ng:controller="FormController" class="example">
23+
24+
<label>Name:</label><br/>
25+
<input type="text" name="user.name" ng:required/> <br/><br/>
26+
27+
<label>Address:</label><br/>
28+
<input type="text" name="user.address.line1" size="33" ng:required/> <br/>
29+
<input type="text" name="user.address.city" size="12" ng:required/>,
30+
<input type="text" name="user.address.state" size="2" ng:required ng:validate="regexp:state"/>
31+
<input type="text" name="user.address.zip" size="5" ng:required ng:validate="regexp:zip"/><br/><br/>
32+
33+
<label>Phone:</label>
34+
[ <a href="" ng:click="user.contacts.$add()">add</a> ]
35+
<div ng:repeat="contact in user.contacts">
36+
<select name="contact.type">
37+
<option>email</option>
38+
<option>phone</option>
39+
<option>pager</option>
40+
<option>IM</option>
41+
</select>
42+
<input type="text" name="contact.value" ng:required/>
43+
[ <a href="" ng:click="user.contacts.$remove(contact)">X</a> ]
44+
</div>
45+
<hr/>
46+
Debug View:
47+
<pre>user={{user}}</pre>
48+
</div>
49+
50+
</doc:source>
51+
<doc:scenario>
52+
it('should show debug', function(){
53+
expect(binding('user')).toMatch(/John Smith/);
54+
});
55+
iit('should add contact', function(){
56+
using('.example').element('a:contains(add)').click();
57+
using('.example div:last').input('contact.value').enter('you@example.org');
58+
expect(binding('user')).toMatch(/\(234\) 555\-1212/);
59+
expect(binding('user')).toMatch(/you@example.org/);
60+
});
61+
62+
iit('should remove contact', function(){
63+
});
64+
65+
iit('should validate zip', function(){
66+
});
67+
68+
iit('should validate state', function(){
69+
});
70+
</doc:scenario>
71+
</doc:example>
72+
73+
74+
# Things to notice
75+
76+
* The user data model is initialized {@link angular.ng:controller controller} and is available in
77+
the {@link angular.scope scope} with the initial data.
78+
* For debugging purposes we have included a debug view of the model to better understand what
79+
is going on.
80+
* The {@link angular.widget.HTML input widgets} simply refer to the model and are auto bound.
81+
* The inputs {@link angular.validator validate}. (Try leaving them blank or entering non digits
82+
in the zip field)
83+
* In your application you can simply read from or write to the model and the form will be updated.
84+
* By clicking the 'add' link you are adding new items into the `user.contacts` array which are then
85+
reflected in the view.

docs/cookbook.formadvanced.ngdoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
@workInProgress
2+
@ngdoc overview
3+
@name Cookbook: Advanced Form
4+
@description

docs/cookbook.helloworld.ngdoc

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
@workInProgress
2+
@ngdoc overview
3+
@name Cookbook: Hello World
4+
@description
5+
6+
<doc:example>
7+
<doc:source>
8+
Your name: <input type="text" name="name" value="World"/>
9+
<hr/>
10+
Hello {{name}}!
11+
</doc:source>
12+
<doc:scenario>
13+
iit('should change the binding when user enters text', function(){
14+
expect(binding('name')).toEqual('World');
15+
input('name').enter('angular');
16+
expect(binding('name')).toEqual('angular');
17+
});
18+
</doc:scenario>
19+
</doc:example>
20+
21+
# Things to notice
22+
23+
Take a look through the source and note:
24+
25+
* The script tag that {@link guide.bootstrap bootstraps} the angular environment.
26+
* The text {@link angular.widget.HTML input widget} which is bound to the greeting name text.
27+
* No need for listener registration and event firing on change events.
28+
* The implicit presence of the `name` variable which is in the root {@link angular.scope scope}.
29+
* The double curly brace `{{markup}}`, which binds the name variable to the greeting text.
30+
* The concept of {@link guide.data-binding data binding}, which reflects any changes to the
31+
input field in the greeting text.

docs/cookbook.mvc.ngdoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
@workInProgress
2+
@ngdoc overview
3+
@name Cookbook: MVC
4+
@description

docs/cookbook.ngdoc

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
@workInProgress
2+
@ngdoc overview
3+
@name Cookbook
4+
@description
5+
6+
Welcome to the angular cookbook. Here we will show you typical uses of angular by example.
7+
8+
9+
# Hello World
10+
11+
{@link cookbook.helloworld Hello World}: The simplest possible application that demonstrates the
12+
classic Hello World!
13+
14+
15+
# Basic Form
16+
17+
{@link cookbook.form Basic Form}: Displaying forms to the user for editing is the bread and butter
18+
of web applications. Angular makes forms easy through bidirectional data binding.
19+
20+
21+
# Advanced Form
22+
23+
{@link cookbook.formadvanced Advanced Form}: Taking the form example to the next level and
24+
providing advanced features such as dirty detection, form reverting and submit disabling if
25+
validation errors exist.
26+
27+
28+
# Model View Controller
29+
30+
{@link cookbook.mvc MVC}: Tic-Tac-Toe: Model View Controller (MVC) is a time-tested design pattern
31+
to separate the behavior (JavaScript controller) from the presentation (HTML view). This
32+
separation aids in maintainability and testability of your project.
33+
34+
35+
# Multi-page App and Deep Linking
36+
37+
{@link cookbook.deeplinking Deep Linking}: An AJAX application never navigates away from the
38+
first page it loads. Instead, it changes the DOM of its single page. Eliminating full-page reloads
39+
is what makes AJAX apps responsive, but it creates a problem in that apps with a single URL
40+
prevent you from emailing links to a particular screen within your application.
41+
42+
Deep linking tries to solve this by changing the URL anchor without reloading a page, thus
43+
allowing you to send links to specific screens in your app.
44+
45+
46+
# Services
47+
48+
{@link angular.service Services}: Services are long lived objects in your applications that are
49+
available across controllers. A collection of useful services are pre-bundled with angular but you
50+
will likely add your own. Services are initialized using dependency injection, which resolves the
51+
order of initialization. This safeguards you from the perils of global state (a common way to
52+
implement long lived objects).
53+
54+
55+
# External Resources
56+
57+
{@link cookbook.buzz Resources}: Web applications must be able to communicate with the external
58+
services to get and update data. Resources are the abstractions of external URLs which are
59+
specially tailored to angular data binding.
60+

docs/fag.ngdoc

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
@workInProgress
2+
@ngdoc overview
3+
@name FAQ
4+
@description
5+
6+
#FAQ
7+
8+
### Why is this project called "angular"? Why is the namespace called "ng"?
9+
10+
Because HTML has angular brackets and "ng" sounds like "angular".
11+
12+
### Is <angular/> an HTML5 tag?
13+
14+
No, <angular/> is not an HTML5 tag. angular is an orthogonal project to HTML5; you can use the two
15+
together.
16+
17+
### Is angular a {library, framework, DOM manipulation library, widget library, native plugin}?
18+
19+
No, angular is none of these. You don't call its functions, it does not call your functions,
20+
it does not provide a way to manipulate DOM, but does provide primitives to create UI projections
21+
of your data. There are lots of existing widget libraries which you can integrate with angular.
22+
It is 100% JavaScript, 100% client side and compatible with both desktop and mobile browsers.
23+
24+
### Do I need to worry about security holes in angular?
25+
26+
Like with any technology, angular is not impervious to attack. angular does, however, provide
27+
built-in protection from basic security holes including cross-site scripting and HTML injection
28+
attacks. angular does round-trip escaping on all strings for you.
29+
30+
### Can I download the source, build, and host the angular environment locally?
31+
32+
Yes. See instructions in {@link guide.downloading downloading}.
33+
34+
### Is angular a templating system?
35+
36+
At the highest level, angular does look like a just another templating system. But there is one
37+
important reason why angular templating system is different and makes it very good fit for
38+
application development: bidirectional data binding. The template is compiled on the browser and
39+
the compilation step produces a live view. This means you, the developer, don't need to write
40+
code to constantly sync the view with the model and the model with the view as in other
41+
templating systems.
42+
43+
### What browsers does angular work with?
44+
45+
Webkit-based browsers (Safari, Chrome, iPhone, Android, WebOS, BlackBerry 6), Firefox, IE6 and
46+
above. Note that CSS only works on IE7 and above.
47+
48+
### What's angular's performance like?
49+
50+
angular takes ~300ms to load, render, and compile. In Chrome it uses about 2-5MB of memory. Your
51+
app's performance will vary depending on how many bindings you use.
52+
53+
### How big is the angular bootstrap JS file that I need to include?
54+
55+
The size of the library itself is < 50KB compressed and obfuscated.
56+
57+
### Can I use the open-source Closure Library with angular?
58+
59+
Yes, you can use widgets from the {@link http://code.google.com/closure/library Closure Library}
60+
in angular.
61+
62+
### Does angular use the jQuery library?
63+
64+
Yes, angular uses {@link http://jquery.com/ jQuery}, the open source DOM manipulation library.
65+
If jQuery is not present in your script path, angular falls back on its own implementation of
66+
{@link angular.element jQuery lite}. If jQuery is present in the path, angular uses it to
67+
manipulate the DOM.
68+
69+
### What is testability like in angular?
70+
71+
Very testable. It has an integrated dependency injection framework. See
72+
{@link angular.service service} for details.
73+
74+
### How can I learn more about angular?
75+
76+
Watch the July 28, 2010 talk
77+
"{@link http://www.youtube.com/watch?v=elvcgVSynRg| Angular: A Radically Different Way of Building AJAX Apps}".
78+
79+
### How is angular licensed?
80+
81+
The MIT License.

docs/img/angular_parts.png

53.1 KB
Loading

docs/img/helloworld.png

11.5 KB
Loading

0 commit comments

Comments
 (0)