Skip to content

Commit 772ddb9

Browse files
committed
docs(directive, module): add various missing docs and fix existing docs
1 parent 7f6c109 commit 772ddb9

File tree

5 files changed

+56
-26
lines changed

5 files changed

+56
-26
lines changed

docs/content/api/angular.module.ng.$compileProvider.directive.ngdoc

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,6 @@ The full skeleton of the directive is shown here:
241241
transclude: false,
242242
restrict: 'A',
243243
scope: false,
244-
local: {},
245244
compile: function compile(tElement, tAttrs, transclude) {
246245
return {
247246
pre: function preLink(scope, iElement, iAttrs, controller) { ... },
@@ -319,35 +318,35 @@ compiler}. The attributes are:
319318
* `{}` (object hash) - then a new 'isolate' scope is created. The 'isolate' scope differs from
320319
normal scope that it does not prototypically inherit from the parent scope. This is useful
321320
when creating reusable components, which should not accidentally read or modify data in
322-
parent scope. <br/>
321+
parent scope. <br/>
323322
The 'isolate' scope takes an object hash which defines a set of local scope properties
324323
derived from the parent scope. These local properties are useful for aliasing values for
325324
templates. Locals definition is a hash of normalized element attribute name to their
326325
corresponding binding strategy. Valid binding strategies are:
327326

328327
* `attribute` - one time read of element attribute value and save it to widget scope. <br/>
329-
Given `<widget my-attr='abc'>` and widget definition of `locals: {myAttr:'attribute'}`,
328+
Given `<widget my-attr='abc'>` and widget definition of `scope: {myAttr:'attribute'}`,
330329
then widget scope property `myAttr` will be `"abc"`.
331330

332331
* `evaluate` - one time evaluation of expression stored in the attribute. <br/> Given
333-
`<widget my-attr='name'>` and widget definition of `locals: {myAttr:'evaluate'}`, and
332+
`<widget my-attr='name'>` and widget definition of `scope: {myAttr:'evaluate'}`, and
334333
parent scope `{name:'angular'}` then widget scope property `myAttr` will be `"angular"`.
335334

336335
* `bind` - Set up one way binding from the element attribute to the widget scope. <br/>
337-
Given `<widget my-attr='{{name}}'>` and widget definition of `locals: {myAttr:'bind'}`,
336+
Given `<widget my-attr='{{name}}'>` and widget definition of `scope: {myAttr:'bind'}`,
338337
and parent scope `{name:'angular'}` then widget scope property `myAttr` will be
339338
`"angular"`, but any changes in the parent scope will be reflected in the widget scope.
340339

341340
* `accessor` - Set up getter/setter function for the expression in the widget element
342341
attribute to the widget scope. <br/> Given `<widget my-attr='name'>` and widget definition
343-
of `locals: {myAttr:'prop'}`, and parent scope `{name:'angular'}` then widget scope
342+
of `scope: {myAttr:'prop'}`, and parent scope `{name:'angular'}` then widget scope
344343
property `myAttr` will be a function such that `myAttr()` will return `"angular"` and
345344
`myAttr('new value')` will update the parent scope `name` property. This is useful for
346345
treating the element as a data-model for reading/writing.
347346

348-
* `expression` - Treat element attribute as an expression to be executed in form of an event.
347+
* `expression` - Treat element attribute as an expression to be executed on the parent scope.
349348
<br/>
350-
Given `<widget my-attr='doSomething()'>` and widget definition of `locals:
349+
Given `<widget my-attr='doSomething()'>` and widget definition of `scope:
351350
{myAttr:'expression'}`, and parent scope `{doSomething:function() {}}` then calling the
352351
widget scope function `myAttr` will execute the expression against the parent scope.
353352

@@ -371,7 +370,7 @@ compiler}. The attributes are:
371370

372371

373372
* `inject` (object hash) - Specifies a way to inject bindings into a controller. Injection
374-
definition is a hash of normalized element attribute name to their corresponding binding
373+
definition is a hash of normalized element attribute names to their corresponding binding
375374
strategy. Valid binding strategies are:
376375

377376
* `attribute` - inject attribute value. <br/>
@@ -421,10 +420,10 @@ compiler}. The attributes are:
421420
transclusion function which is pre-bound to the correct scope. In a typical setup the widget
422421
creates an `isolate` scope, but the transclusion is not a child, but a sibling of the `isolate`
423422
scope. This makes it possible for the widget to have private state, and the transclusion to
424-
be bound to the pre-`isolate` scope.
423+
be bound to the parent (pre-`isolate`) scope.
425424

426425
* `true` - transclude the content of the directive.
427-
* `element` - transclude the whole element including any directives defined at lower priority.
426+
* `'element'` - transclude the whole element including any directives defined at lower priority.
428427

429428

430429
* `compile`: This is the compile function described in the section below.
@@ -569,11 +568,11 @@ This will not render properly, unless we do some scope magic.
569568
The first issue we have to solve is that the dialog box template expect `title` to be defined, but
570569
the place of instantiation would like to bind to `username`. Furthermore the buttons expect `onOk`
571570
as well as `onCancel` functions to be present in the scope. This limits the usefulness of the
572-
widget. To solve the mapping issue we use the `locals` to create local variables which the
573-
template expects as follows
571+
widget. To solve the mapping issue we use the `locals` to create local variables which the template
572+
expects as follows:
574573

575574
<pre>
576-
locals: {
575+
scope: {
577576
title: 'bind', // set up title to accept data-binding
578577
onOk: 'exp', // create a delegate onOk function
579578
onCancel: 'exp', // create a delegate onCancel function

docs/content/guide/module.ngdoc

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ approach:
1919

2020
# The Basics
2121

22-
Ok i am in a hurry how do i get a Hello World module working?
22+
Ok, I'm in a hurry how do i get a Hello World module working?
2323

2424
Important things to notice:
2525

@@ -116,7 +116,7 @@ The above is only a suggestion, so feel free to tailor it to your needs.
116116

117117
# Module Loading & Dependencies
118118

119-
A module is a collection of configuration and run block which get applied to the application
119+
A module is a collection of configuration and run blocks which get applied to the application
120120
during the bootstrap process. In its simplest form the module consist of collection of two kinds
121121
of blocks:
122122

@@ -173,8 +173,8 @@ to it are constant definitions, which are placed at the beginning of all configu
173173

174174
Run blocks are the closest thing in Angular to the main method. A run block is the code which
175175
needs to run to kickstart the application. It is executed after all of the service have been
176-
configured and the injector has been created. Run blocks typically contain code which is hard
177-
to unit-test, and for this reason should be declared in isolated modules, so that they can be
176+
configured and the injector has been created. Run blocks typically contain code which is hard
177+
to unit-test, and for this reason should be declared in isolated modules, so that they can be
178178
ignored in the unit-tests.
179179

180180
## Dependencies
@@ -223,19 +223,19 @@ In all of these examples we are going to assume this module definition:
223223
Let's write some tests:
224224
<pre>
225225
describe('myApp', function() {
226-
// load the application relevant modules then load a special
227-
// test module which overrides the $window with mock version,
228-
// so that calling window.alert() will not block the test
226+
// load the application relevant modules then load a special
227+
// test module which overrides the $window with mock version,
228+
// so that calling window.alert() will not block the test
229229
// runner with a real alert box. This is an example of overriding
230230
// configuration information in tests.
231231
beforeEach(module('greetMod', function($provide) {
232-
$provide.value('$window', {
233-
alert: jasmine.createSpy('alert')
232+
$provide.value('$window', {
233+
alert: jasmine.createSpy('alert')
234234
});
235235
});
236236

237237
// The inject() will create the injector and inject the greet and
238-
// $window into the tests. The test need not concern itself with
238+
// $window into the tests. The test need not concern itself with
239239
// wiring of the application, only with testing it.
240240
it('should alert on $window', inject(function(greet, $window) {
241241
greet('World');

src/directives.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,13 +196,44 @@ var ngBindDirective = ngDirective(function(scope, element, attr) {
196196
});
197197
});
198198

199+
200+
/**
201+
* @ngdoc directive
202+
* @name angular.module.ng.$compileProvider.directive.ng:bind-html-unsafe
203+
*
204+
* @description
205+
* Creates a binding that will innerHTML the result of evaluating the `expression` into the current
206+
* element. *The innerHTML-ed content will not be sanitized!* You should use this directive only if
207+
* {@link angular.module.ng.$compileProvider.directive.ng:bind-html ng:bind-html} directive is too
208+
* restrictive and when you absolutely trust the source of the content you are binding to.
209+
*
210+
* See {@link angular.module.ng.$sanitize $sanitize} docs for examples.
211+
*
212+
* @element ANY
213+
* @param {expression} expression {@link guide/dev_guide.expressions Expression} to evaluate.
214+
*/
199215
var ngBindHtmlUnsafeDirective = ngDirective(function(scope, element, attr) {
200216
element.addClass('ng-binding').data('$binding', attr.ngBindHtmlUnsafe);
201217
scope.$watch(attr.ngBindHtmlUnsafe, function(value) {
202218
element.html(value == undefined ? '' : value);
203219
});
204220
});
205221

222+
223+
/**
224+
* @ngdoc directive
225+
* @name angular.module.ng.$compileProvider.directive.ng:bind-html
226+
*
227+
* @description
228+
* Creates a binding that will sanitize the result of evaluating the `expression` with the
229+
* {@link angular.module.ng.$sanitize $sanitize} service and innerHTML the result into the current
230+
* element.
231+
*
232+
* See {@link angular.module.ng.$sanitize $sanitize} docs for examples.
233+
*
234+
* @element ANY
235+
* @param {expression} expression {@link guide/dev_guide.expressions Expression} to evaluate.
236+
*/
206237
var ngBindHtmlDirective = ['$sanitize', function($sanitize) {
207238
return function(scope, element, attr) {
208239
element.addClass('ng-binding').data('$binding', attr.ngBindHtml);

src/service/sanitize.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
</tr>
6464
<tr id="escaped-html">
6565
<td>no filter</td>
66-
<td><pre>&lt;div ng:bind-="snippet"&gt;<br/>&lt;/div&gt;</pre></td>
66+
<td><pre>&lt;div ng:bind="snippet"&gt;<br/>&lt;/div&gt;</pre></td>
6767
<td><div ng:bind="snippet"></div></td>
6868
</tr>
6969
<tr id="html-unsafe-filter">

src/widgets.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,7 @@ var ngPluralizeDirective = ['$locale', '$interpolate', function($locale, $interp
805805
restrict: 'EA',
806806
link: function(scope, element, attr) {
807807
var numberExp = attr.count,
808-
whenExp = element.attr(attr.$attr.when), // this is becaues we have {{}} in attrs
808+
whenExp = element.attr(attr.$attr.when), // this is because we have {{}} in attrs
809809
offset = attr.offset || 0,
810810
whens = scope.$eval(whenExp),
811811
whensExpFns = {};

0 commit comments

Comments
 (0)