From c35b0a7907de1535269876668c345ce944681804 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Mon, 6 Jun 2011 22:02:30 -0700 Subject: yet another docs batch --- docs/content/api/angular.attrMarkup.ngdoc | 15 --- docs/content/api/angular.directive.ngdoc | 53 -------- docs/content/api/angular.element.ngdoc | 49 -------- docs/content/api/angular.markup.ngdoc | 66 ---------- docs/content/api/angular.service.ngdoc | 195 ++++-------------------------- docs/content/api/index.ngdoc | 1 + 6 files changed, 27 insertions(+), 352 deletions(-) delete mode 100644 docs/content/api/angular.attrMarkup.ngdoc delete mode 100644 docs/content/api/angular.directive.ngdoc delete mode 100644 docs/content/api/angular.element.ngdoc delete mode 100644 docs/content/api/angular.markup.ngdoc (limited to 'docs/content/api') diff --git a/docs/content/api/angular.attrMarkup.ngdoc b/docs/content/api/angular.attrMarkup.ngdoc deleted file mode 100644 index aad20866..00000000 --- a/docs/content/api/angular.attrMarkup.ngdoc +++ /dev/null @@ -1,15 +0,0 @@ -@workInProgress -@ngdoc overview -@name angular.attrMarkup - -@description -Attribute markup extends the angular compiler in a very similar way as {@link angular.markup} except -that it allows you to modify the state of the attribute text rather then the content of a node. - -
-angular.attrMarkup('extraClass', function(attrValue, attrName, element){
- if (attrName == 'additional-class') {
- element.addClass(attrValue);
- }
-});
-
diff --git a/docs/content/api/angular.directive.ngdoc b/docs/content/api/angular.directive.ngdoc
deleted file mode 100644
index 277830b9..00000000
--- a/docs/content/api/angular.directive.ngdoc
+++ /dev/null
@@ -1,53 +0,0 @@
-@workInProgress
-@ngdoc overview
-@name angular.directive
-@namespace Namespace for all directives.
-
-@description
-A directive is an HTML attribute that you can use in an existing HTML element type or in a
-DOM element type that you create as {@link angular.widget}, to modify that element's
-properties. You can use any number of directives per element.
-
-For example, you can add the ng:bind directive as an attribute of an HTML span element, as in
-``. How does this work? The compiler passes the attribute value
-`1+2` to the ng:bind extension, which in turn tells the {@link angular.scope} to watch that
-expression and report changes. On any change it sets the span text to the expression value.
-
-Here's how to define {@link angular.directive.ng:bind ng:bind}:
-
- angular.directive('ng:bind', function(expression, compiledElement) {
- var compiler = this;
- return function(linkElement) {
- var currentScope = this;
- currentScope.$watch(expression, function(value) {
- linkElement.text(value);
- });
- };
- });
-
-
-# Directive vs. Attribute Widget
-Both [attribute widgets](#!angular.widget) and directives can compile a DOM element
-attribute. So why have two different ways to do the same thing? The answer is that order
-matters, but we have no control over the order in which attributes are read. To solve this
-we apply attribute widget before the directive.
-
-For example, consider this piece of HTML, which uses the `ng:repeat`, `ng:init`,
-and `ng:bind` widget and directives:
--
-{{expression}}
-
-
-to:
-
-- -- -For example `{{1+2}}` is easier to write and understand than ``. The -expanded elements are then {@link guide.compiler compiled} normally. - -# Custom markup -Let's say you want to define this shorthand for a horizontal rule: `---` for `
-header ---- -footer -- -should translate to: -
-header -- -Here's how the angular compiler could be extended to achieve this: -
-footer -
-angular.markup('---', function(text, textNode, parentElement) {
- var compiler = this;
- var index = text.indexOf('---');
- if (index > -1) {
- var before = compiler.text(text.substring(0, index));
- var hr = compiler.element('hr');
- var after = compiler.text(text.substring(index + 3));
- textNode.after(after);
- textNode.after(hr);
- textNode.after(before);
- textNode.remove();
- }
-});
-
-
-Unlike {@link angular.widget widgets} and {@link angular.directive directives}, in which the
-compiler matches the name of handler function to a DOM element or attribute name, for markup the
-compiler calls every markup handler for every text node, giving the handler a chance to transform
-the text. The markup handler needs to find all the matches in the text.
diff --git a/docs/content/api/angular.service.ngdoc b/docs/content/api/angular.service.ngdoc
index 0d3406e5..9a191921 100644
--- a/docs/content/api/angular.service.ngdoc
+++ b/docs/content/api/angular.service.ngdoc
@@ -1,175 +1,32 @@
@workInProgress
@ngdoc overview
@name angular.service
-
@description
-# Overview
-Services are substituable objects, which are wired together using dependency injection (DI).
-Each service could have dependencies (other services), which are passed in constructor.
-Because JS is dynamicaly typed language, dependency injection can not use static types
-to identify these dependencies, so each service must explicitely define its dependencies.
-This is done by `$inject` property.
-
-
-# Built-in services
-angular provides a set of services for common operations. These services can be overriden by custom
-services if needed.
-
-Like other core angular variables and identifiers, the built-in services always start with `$`.
-
- * {@link angular.service.$browser $browser}
- * {@link angular.service.$window $window}
- * {@link angular.service.$document $document}
- * {@link angular.service.$location $location}
- * {@link angular.service.$log $log}
- * {@link angular.service.$exceptionHandler $exceptionHandler}
- * {@link angular.service.$hover $hover}
- * {@link angular.service.$invalidWidgets $invalidWidgets}
- * {@link angular.service.$route $route}
- * {@link angular.service.$xhr $xhr}
- * {@link angular.service.$xhr.error $xhr.error}
- * {@link angular.service.$xhr.bulk $xhr.bulk}
- * {@link angular.service.$xhr.cache $xhr.cache}
- * {@link angular.service.$resource $resource}
- * {@link angular.service.$cookies $cookies}
- * {@link angular.service.$cookieStore $cookieStore}
-
-# Writing your own custom services
-angular provides only set of basic services, so for any nontrivial application it will be necessary
-to write one or more custom services. To do so, a factory function that creates a services needs to
-be registered with angular's dependency injector. This factory function must return an object - the
-service (it is not called with the `new` operator).
-
-**angular.service** accepts three parameters:
-
- - `{string} name` - Name of the service.
- - `{function()} factory` - Factory function (called just once by DI).
- - `{Object} config` - Configuration object with following properties:
- - `$inject` - {Array.
- angular.service('notify', function(win) {
- var msgs = [];
- return function(msg) {
- msgs.push(msg);
- if (msgs.length == 3) {
- win.alert(msgs.join("\n"));
- msgs = [];
- }
- };
- }, {$inject: ['$window']});
-
-
-And here is a unit test for this service. We use Jasmine spy (mock) instead of real browser's alert.
-
-var mock, notify;
-
-beforeEach(function() {
- mock = {alert: jasmine.createSpy()};
- notify = angular.service('notify')(mock);
-});
-
-it('should not alert first two notifications', function() {
- notify('one');
- notify('two');
- expect(mock.alert).not.toHaveBeenCalled();
-});
-
-it('should alert all after third notification', function() {
- notify('one');
- notify('two');
- notify('three');
- expect(mock.alert).toHaveBeenCalledWith("one\ntwo\nthree");
-});
-
-it('should clear messages after alert', function() {
- notify('one');
- notify('two');
- notify('third');
- notify('more');
- notify('two');
- notify('third');
- expect(mock.alert.callCount).toEqual(2);
- expect(mock.alert.mostRecentCall.args).toEqual(["more\ntwo\nthird"]);
-});
-
-
-# Injecting services into controllers
-Using services as dependencies for controllers is very similar to using them as dependencies for
-another service.
-
-JavaScript is dynamic language, so DI is not able to figure out which services to inject by
-static types (like in static typed languages). Therefore you must specify the service name
-by the `$inject` property - it's an array that contains strings with names of services to be
-injected. The name must match the id that service has been registered as with angular.
-The order of the services in the array matters, because this order will be used when calling
-the factory function with injected parameters. The names of parameters in factory function
-don't matter, but by convention they match the service ids.
-
-function myController($loc, $log) {
- this.firstMethod = function() {
- // use $location service
- $loc.setHash();
- };
- this.secondMethod = function() {
- // use $log service
- $log.info('...');
- };
-}
-// which services to inject ?
-myController.$inject = ['$location', '$log'];
-
-
-@example
-Let's try this simple notify service, injected into the controller...
- - -