diff --git a/docs/component-spec/docsSearchSpec.js b/docs/component-spec/docsSearchSpec.js index 38e6937a9ce8..f5f8d36ec999 100644 --- a/docs/component-spec/docsSearchSpec.js +++ b/docs/component-spec/docsSearchSpec.js @@ -13,8 +13,7 @@ describe("docsSearch", function() { results[0] = { section: 'tutorial', shortName: 'item one', keywords: 'item, one, 1' }; results[1] = { section: 'tutorial', shortName: 'item man', keywords: 'item, man' }; results[2] = { section: 'api', shortName: 'item other', keywords: 'item, other' }; - results[3] = { section: 'cookbook', shortName: 'item cookbook', keywords: 'item, other' }; - results[4] = { section: 'api', shortName: 'ngRepeat', keywords: 'item, other' }; + results[3] = { section: 'api', shortName: 'ngRepeat', keywords: 'item, other' }; $provide.value('NG_PAGES', results); $provide.factory('lunrSearch', function() { @@ -41,19 +40,14 @@ describe("docsSearch", function() { expect(items['api'].length).toBe(2); })); - it("should place cookbook items in the tutorial", inject(function(docsSearch) { - var items = docsSearch('item'); - expect(items['tutorial'].length).toBe(3); - })); - it("should return all results without a search", inject(function(docsSearch) { var items = docsSearch(); - expect(items['tutorial'].length).toBe(3); + expect(items['tutorial'].length).toBe(2); expect(items['api'].length).toBe(2); })); it("should store values with and without a ng prefix", inject(function(docsSearch) { - expect(interceptedLunrResults[4].title).toBe('ngRepeat repeat'); + expect(interceptedLunrResults[3].title).toBe('ngRepeat repeat'); })); }); diff --git a/docs/content/cookbook/advancedform.ngdoc b/docs/content/cookbook/advancedform.ngdoc deleted file mode 100644 index bcf8069a1072..000000000000 --- a/docs/content/cookbook/advancedform.ngdoc +++ /dev/null @@ -1,122 +0,0 @@ -@ngdoc overview -@name Cookbook: Advanced Form -@description - -Here we extend the basic form example to include common features such as reverting, dirty state -detection, and preventing invalid form submission. - - - - -
- -
- -
-

- -
-
- , - -

- - - [ add ] -
- - - [ X ] -
- - -
- -
- Debug View: -
form={{form}}
-
-
- - it('should enable save button', function() { - expect(element(':button:contains(Save)').attr('disabled')).toBeTruthy(); - input('form.name').enter(''); - expect(element(':button:contains(Save)').attr('disabled')).toBeTruthy(); - input('form.name').enter('change'); - expect(element(':button:contains(Save)').attr('disabled')).toBeFalsy(); - element(':button:contains(Save)').click(); - expect(element(':button:contains(Save)').attr('disabled')).toBeTruthy(); - }); - it('should enable cancel button', function() { - expect(element(':button:contains(Cancel)').attr('disabled')).toBeTruthy(); - input('form.name').enter('change'); - expect(element(':button:contains(Cancel)').attr('disabled')).toBeFalsy(); - element(':button:contains(Cancel)').click(); - expect(element(':button:contains(Cancel)').attr('disabled')).toBeTruthy(); - expect(element(':input[ng\\:model="form.name"]').val()).toEqual('John Smith'); - }); - -
- - -#Things to notice - -* Cancel & save buttons are only enabled if the form is dirty — there is something to cancel or -save. -* Save button is only enabled if there are no validation errors on the form. -* Cancel reverts the form changes back to original state. -* Save updates the internal model of the form. -* Debug view shows the two models. One presented to the user form and the other being the pristine -copy master. diff --git a/docs/content/cookbook/buzz.ngdoc b/docs/content/cookbook/buzz.ngdoc deleted file mode 100644 index 00db35cf7b16..000000000000 --- a/docs/content/cookbook/buzz.ngdoc +++ /dev/null @@ -1,63 +0,0 @@ -@ngdoc overview -@name Cookbook: Resources - Buzz -@description - -External resources are URLs that provide JSON data, which are then rendered with the help of -templates. Angular has a resource factory that can be used to give names to the URLs and then -attach behavior to them. For example you can use the -{@link http://code.google.com/apis/buzz/v1/getting_started.html#background-operations| Google Buzz -API} -to retrieve Buzz activity and comments. - - - - -
- - -
-
-

- - {{item.actor.name}} - - Expand replies: {{item.links.replies[0].count}} - -

- {{item.object.content | html}} -
- - {{reply.actor.name}}: - {{reply.content | html}} -
-
-
-
- - xit('fetch buzz and expand', function() { - element(':button:contains(fetch)').click(); - expect(repeater('div.buzz').count()).toBeGreaterThan(0); - element('.buzz a:contains(Expand replies):first').click(); - expect(repeater('div.reply').count()).toBeGreaterThan(0); - }); - -
diff --git a/docs/content/cookbook/deeplinking.ngdoc b/docs/content/cookbook/deeplinking.ngdoc deleted file mode 100644 index bdcf0b0978f0..000000000000 --- a/docs/content/cookbook/deeplinking.ngdoc +++ /dev/null @@ -1,151 +0,0 @@ -@ngdoc overview -@name Cookbook: Deep Linking -@description - -Deep linking allows you to encode the state of the application in the URL so that it can be -bookmarked and the application can be restored from the URL to the same state. - -While Angular does not force you to deal with bookmarks in any particular way, it has services -which make the common case described here very easy to implement. - -# Assumptions - -Your application consists of a single HTML page which bootstraps the application. We will refer -to this page as the chrome. -Your application is divided into several screens (or views) which the user can visit. For example, -the home screen, settings screen, details screen, etc. For each of these screens, we would like to -assign a URL so that it can be bookmarked and later restored. Each of these screens will be -associated with a controller which define the screen's behavior. The most common case is that the -screen will be constructed from an HTML snippet, which we will refer to as the partial. Screens can -have multiple partials, but a single partial is the most common construct. This example makes the -partial boundary visible using a blue line. - -You can make a routing table which shows which URL maps to which partial view template and which -controller. - -# Example - -In this example we have a simple app which consist of two screens: - -* Welcome: url `welcome` Show the user contact information. -* Settings: url `settings` Show an edit screen for user contact information. - - - - angular.module('deepLinking', ['ngRoute', 'ngSanitize']) - .config(function($routeProvider) { - $routeProvider. - when("/welcome", {templateUrl:'welcome.html', controller:WelcomeCntl}). - when("/settings", {templateUrl:'settings.html', controller:SettingsCntl}); - }); - - AppCntl.$inject = ['$scope', '$route'] - function AppCntl($scope, $route) { - $scope.$route = $route; - - // initialize the model to something useful - $scope.person = { - name:'anonymous', - contacts:[{type:'email', url:'anonymous@example.com'}] - }; - } - - function WelcomeCntl($scope) { - $scope.greet = function() { - alert("Hello " + $scope.person.name); - }; - } - - function SettingsCntl($scope, $location) { - $scope.cancel = function() { - $scope.form = angular.copy($scope.person); - }; - - $scope.save = function() { - angular.copy($scope.form, $scope.person); - $location.path('/welcome'); - }; - - $scope.cancel(); - } - - - [ng-view] { - border: 1px solid blue; - margin: 0; - padding:1em; - } - - .partial-info { - background-color: blue; - color: white; - padding: 3px; - } - - -
-

Your App Chrome

- [ Welcome | Settings ] -
- - Partial: {{$route.current.template}} - -
- Your app footer -
-
- - - - -
- - - [ X ] -
-
- [ add ] -
- - - -
- - Hello {{person.name}}, -
- Your contact information: -
{{contact.type}}: - -
-
-
- - it('should navigate to URL', function() { - element('a:contains(Welcome)').click(); - expect(element('[ng-view]').text()).toMatch(/Hello anonymous/); - element('a:contains(Settings)').click(); - input('form.name').enter('yourname'); - element(':button:contains(Save)').click(); - element('a:contains(Welcome)').click(); - expect(element('[ng-view]').text()).toMatch(/Hello yourname/); - }); - -
- - - -# Things to notice - -* Routes are defined in the `AppCntl` class. The initialization of the controller causes the - initialization of the {@link api/ngRoute.$route $route} service with the proper URL - routes. -* The {@link api/ngRoute.$route $route} service then watches the URL and instantiates the - appropriate controller when the URL changes. -* The {@link api/ngRoute.directive:ngView ngView} widget loads the - view when the URL changes. It also sets the view scope to the newly instantiated controller. -* Changing the URL is sufficient to change the controller and view. It makes no difference whether - the URL is changed programmatically or by the user. diff --git a/docs/content/cookbook/form.ngdoc b/docs/content/cookbook/form.ngdoc deleted file mode 100644 index aaa49d2f0d06..000000000000 --- a/docs/content/cookbook/form.ngdoc +++ /dev/null @@ -1,114 +0,0 @@ -@ngdoc overview -@name Cookbook: Form -@description - -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. - - - - - -
- -
-

- -
-
- , - -

- - - [ add ] -
- - - [ X ] -
-
- Debug View: -
user={{user | json}}
-
- -
- - it('should show debug', function() { - expect(binding('user')).toMatch(/John Smith/); - }); - it('should add contact', function() { - using('.example').element('a:contains(add)').click(); - using('.example div:last').input('contact.value').enter('you@example.org'); - expect(binding('user')).toMatch(/\(234\) 555\-1212/); - expect(binding('user')).toMatch(/you@example.org/); - }); - - it('should remove contact', function() { - using('.example').element('a:contains(X)').click(); - expect(binding('user')).not().toMatch(/\(234\) 555\-1212/); - }); - - it('should validate zip', function() { - expect(using('.example'). - element(':input[ng\\:model="user.address.zip"]'). - prop('className')).not().toMatch(/ng-invalid/); - using('.example').input('user.address.zip').enter('abc'); - expect(using('.example'). - element(':input[ng\\:model="user.address.zip"]'). - prop('className')).toMatch(/ng-invalid/); - }); - - it('should validate state', function() { - expect(using('.example').element(':input[ng\\:model="user.address.state"]').prop('className')) - .not().toMatch(/ng-invalid/); - using('.example').input('user.address.state').enter('XXX'); - expect(using('.example').element(':input[ng\\:model="user.address.state"]').prop('className')) - .toMatch(/ng-invalid/); - }); - -
- - -# Things to notice - -* The user data model is initialized {@link api/ng.directive:ngController controller} and is - available in the {@link api/ng.$rootScope.Scope scope} with the initial data. -* For debugging purposes we have included a debug view of the model to better understand what - is going on. -* The {@link api/ng.directive:input input directives} simply refer - to the model and are data-bound. -* The inputs validate. (Try leaving them blank or entering non digits in the zip field) -* In your application you can simply read from or write to the model and the form will be updated. -* By clicking the 'add' link you are adding new items into the `user.contacts` array which are then - reflected in the view. diff --git a/docs/content/cookbook/helloworld.ngdoc b/docs/content/cookbook/helloworld.ngdoc deleted file mode 100644 index a24f959a7858..000000000000 --- a/docs/content/cookbook/helloworld.ngdoc +++ /dev/null @@ -1,39 +0,0 @@ -@ngdoc overview -@name Cookbook: Hello World -@description - - - - -
- Your name: -
- Hello {{name || "World"}}! -
-
- - it('should change the binding when user enters text', function() { - expect(binding('name')).toEqual('World'); - input('name').enter('angular'); - expect(binding('name')).toEqual('angular'); - }); - -
- -# Things to notice - -Take a look through the source and note: - -* The script tag that {@link guide/bootstrap bootstraps} the Angular environment. -* The text {@link api/ng.directive:input input form control} which is - bound to the greeting name text. -* There is no need for listener registration and event firing on change events. -* The implicit presence of the `name` variable which is in the root {@link api/ng.$rootScope.Scope scope}. -* The double curly brace `{{markup}}`, which binds the name variable to the greeting text. -* The concept of {@link guide/databinding data binding}, which reflects any -changes to the - input field in the greeting text. diff --git a/docs/content/cookbook/index.ngdoc b/docs/content/cookbook/index.ngdoc deleted file mode 100644 index 4fe3eb4dff31..000000000000 --- a/docs/content/cookbook/index.ngdoc +++ /dev/null @@ -1,58 +0,0 @@ -@ngdoc overview -@name Cookbook -@description - -Welcome to the Angular cookbook. Here we will show you typical uses of Angular by example. - - -# Hello World - -{@link helloworld Hello World}: The simplest possible application that demonstrates the -classic Hello World! - - -# Basic Form - -{@link form Basic Form}: Displaying forms to the user for editing is the bread and butter -of web applications. Angular makes forms easy through bidirectional data binding. - - -# Advanced Form - -{@link advancedform Advanced Form}: Taking the form example to the next level and -providing advanced features such as dirty detection, form reverting and submit disabling if -validation errors exist. - - -# Model View Controller - -{@link mvc MVC}: Tic-Tac-Toe: Model View Controller (MVC) is a time-tested design pattern -to separate the behavior (JavaScript controller) from the presentation (HTML view). This -separation aids in maintainability and testability of your project. - - -# Multi-page App and Deep Linking - -{@link deeplinking Deep Linking}: An AJAX application never navigates away from the -first page it loads. Instead, it changes the DOM of its single page. Eliminating full-page reloads -is what makes AJAX apps responsive, but it creates a problem in that apps with a single URL -prevent you from emailing links to a particular screen within your application. - -Deep linking tries to solve this by changing the URL anchor without reloading a page, thus -allowing you to send links to specific screens in your app. - - -# Services - -{@link api/ng Services}: Services are long lived objects in your applications that are -available across controllers. A collection of useful services are pre-bundled with Angular but you -will likely add your own. Services are initialized using dependency injection, which resolves the -order of initialization. This safeguards you from the perils of global state (a common way to -implement long lived objects). - - -# External Resources - -{@link buzz Resources}: Web applications must be able to communicate with the external -services to get and update data. Resources are the abstractions of external URLs which are -specially tailored to Angular data binding. diff --git a/docs/content/cookbook/mvc.ngdoc b/docs/content/cookbook/mvc.ngdoc deleted file mode 100644 index 59f9ef859696..000000000000 --- a/docs/content/cookbook/mvc.ngdoc +++ /dev/null @@ -1,128 +0,0 @@ -@ngdoc overview -@name Cookbook: MVC -@description - -MVC allows for a clean and testable separation between the behavior (controller) and the view -(HTML template). A Controller is just a JavaScript class which is grafted onto the scope of the -view. This makes it very easy for the controller and the view to share the model. - -The model is a set of objects and primitives that are referenced from the Scope ($scope) object. -This makes it very easy to test the controller in isolation since one can simply instantiate the -controller and test without a view, because there is no connection between the controller and the -view. - - - - - - -

Tic-Tac-Toe

-
- Next Player: {{nextMove}} -
Player {{winner}} has won!
- - - - -
{{cell}}
- -
-
- - it('should play a game', function() { - piece(1, 1); - expect(binding('nextMove')).toEqual('O'); - piece(3, 1); - expect(binding('nextMove')).toEqual('X'); - piece(1, 2); - piece(3, 2); - piece(1, 3); - expect(element('.winner').text()).toEqual('Player X has won!'); - }); - - function piece(row, col) { - element('.board tr:nth-child('+row+') td:nth-child('+col+')').click(); - } - -
- - -# Things to notice - -* The controller is defined in JavaScript and has no reference to the rendering logic. -* The controller is instantiated by Angular and injected into the view. -* The controller can be instantiated in isolation (without a view) and the code will still execute. -This makes it very testable. -* The HTML view is a projection of the model. In the above example, the model is stored in the -board variable. -* All of the controller's properties (such as board and nextMove) are available to the view. -* Changing the model changes the view. -* The view can call any controller function. -* In this example, the `setUrl()` and `readUrl()` functions copy the game state to/from the URL's -hash so the browser's back button will undo game steps. See deep-linking. This example calls {@link -api/ng.$rootScope.Scope#methods_$watch $watch()} to set up a listener that invokes `readUrl()` when needed. diff --git a/docs/content/tutorial/the_end.ngdoc b/docs/content/tutorial/the_end.ngdoc index a4fd72a3d598..3a5fb9f8d05c 100644 --- a/docs/content/tutorial/the_end.ngdoc +++ b/docs/content/tutorial/the_end.ngdoc @@ -8,8 +8,6 @@ previous steps using the `git checkout` command. For more details and examples of the Angular concepts we touched on in this tutorial, see the {@link guide/ Developer Guide}. -For several more examples of code, see the {@link cookbook/ Cookbook}. - When you are ready to start developing a project using Angular, we recommend that you bootstrap your development with the {@link https://github.com/angular/angular-seed angular-seed} project. diff --git a/docs/src/templates/.htaccess b/docs/src/templates/.htaccess index e5a74cc4a4d4..aa3ae5435b97 100644 --- a/docs/src/templates/.htaccess +++ b/docs/src/templates/.htaccess @@ -16,4 +16,4 @@ RewriteCond %{HTTP_HOST} ^docs-next\.angularjs\.org$ RewriteRule appcache.manifest http://code.angularjs.org/next/docs/appcache.manifest [R=301] ## HTML5 URL Support ## -RewriteRule ^(guide|api|cookbook|misc|tutorial)(/.*)?$ index.html +RewriteRule ^(guide|api|misc|tutorial)(/.*)?$ index.html diff --git a/docs/src/templates/index.html b/docs/src/templates/index.html index 848490117faf..bc695119653e 100644 --- a/docs/src/templates/index.html +++ b/docs/src/templates/index.html @@ -26,7 +26,7 @@ } var indexFile = (location.pathname.match(/\/(index[^\.]*\.html)/) || ['', ''])[1], - rUrl = /(#!\/|api|guide|misc|tutorial|cookbook|error|index[^\.]*\.html).*$/, + rUrl = /(#!\/|api|guide|misc|tutorial|error|index[^\.]*\.html).*$/, baseUrl = location.href.replace(rUrl, indexFile), jQuery = /index-jq[^\.]*\.html$/.test(baseUrl), debug = /index[^\.]*-debug\.html$/.test(baseUrl), diff --git a/docs/src/templates/js/docs.js b/docs/src/templates/js/docs.js index 587e15659139..dad57aa55e80 100644 --- a/docs/src/templates/js/docs.js +++ b/docs/src/templates/js/docs.js @@ -111,9 +111,6 @@ docsApp.serviceFactory.docsSearch = ['$rootScope','lunrSearch', 'NG_PAGES', angular.forEach(index.search(q), function(result) { var item = NG_PAGES[result.ref]; var section = item.section; - if(section == 'cookbook') { - section = 'tutorial'; - } results[section] = results[section] || []; if(results[section].length < 15) { results[section].push(item); @@ -630,7 +627,6 @@ docsApp.serviceFactory.sections = ['NG_PAGES', function sections(NG_PAGES) { api: [], tutorial: [], misc: [], - cookbook: [], error: [], getPage: function(sectionId, partialId) { var pages = sections[sectionId]; @@ -675,7 +671,7 @@ docsApp.controller.DocsController = function($scope, $rootScope, $location, $win } }; var OFFLINE_COOKIE_NAME = 'ng-offline', - DOCS_PATH = /^\/(api)|(guide)|(cookbook)|(misc)|(tutorial)|(error)/, + DOCS_PATH = /^\/(api)|(guide)|(misc)|(tutorial)|(error)/, INDEX_PATH = /^(\/|\/index[^\.]*.html)$/, GLOBALS = /^angular\.([^\.]+)$/, ERROR = /^([a-zA-Z0-9_$]+:)?([a-zA-Z0-9_$]+)$/, @@ -737,7 +733,6 @@ docsApp.controller.DocsController = function($scope, $rootScope, $location, $win guide: 'Developer Guide', misc: 'Miscellaneous', tutorial: 'Tutorial', - cookbook: 'Examples', error: 'Error Reference' };