diff options
Diffstat (limited to 'docs/content/error/$compile')
| -rw-r--r-- | docs/content/error/$compile/ctreq.ngdoc | 49 | ||||
| -rw-r--r-- | docs/content/error/$compile/iscp.ngdoc | 25 | ||||
| -rw-r--r-- | docs/content/error/$compile/multidir.ngdoc | 17 | ||||
| -rw-r--r-- | docs/content/error/$compile/nodomevents.ngdoc | 20 | ||||
| -rw-r--r-- | docs/content/error/$compile/nonassign.ngdoc | 41 | ||||
| -rw-r--r-- | docs/content/error/$compile/selmulti.ngdoc | 20 | ||||
| -rw-r--r-- | docs/content/error/$compile/tpload.ngdoc | 11 | ||||
| -rw-r--r-- | docs/content/error/$compile/tplrt.ngdoc | 39 | ||||
| -rw-r--r-- | docs/content/error/$compile/uterdir.ngdoc | 34 |
9 files changed, 256 insertions, 0 deletions
diff --git a/docs/content/error/$compile/ctreq.ngdoc b/docs/content/error/$compile/ctreq.ngdoc new file mode 100644 index 00000000..47c876a3 --- /dev/null +++ b/docs/content/error/$compile/ctreq.ngdoc @@ -0,0 +1,49 @@ +@ngdoc error +@name $compile:ctreq +@fullName Missing Required Controller +@description + +This error occurs when {@link ng.$compile HTML compiler} tries to process a directive that specifies the {@link ng.$compile#description_comprehensive-directive-api_directive-definition-object `require` option} in a {@link ng.$compile#description_comprehensive-directive-api directive definition}, +but the required directive controller is not present on the current DOM element (or its ancestor element, if `^` was specified). + +To resolve this error ensure that there is no typo in the required controller name and that the required directive controller is present on the current element. + +If the required controller is expected to be on a ancestor element, make ensure that you prefix the controller name in the `require` definition with `^`. + +If the required controller is optionally requested, use `?` or `^?` to specify that. + + +Example of a directive that requires {@link ng.directive:ngModel ngModel} controller: +``` +myApp.directive('myDirective', function() { + return { + require: 'ngModel', + ... + } +} +``` + +This directive can then be used as: +``` +<input ng-model="some.path" my-directive> +``` + + +Example of a directive that optionally requires a {@link ng.directive:form form} controller from an ancestor: +``` +myApp.directive('myDirective', function() { + return { + require: '^?form', + ... + } +} +``` + +This directive can then be used as: +``` +<form name="myForm"> + <div> + <span my-directive></span> + </div> +</form> +``` diff --git a/docs/content/error/$compile/iscp.ngdoc b/docs/content/error/$compile/iscp.ngdoc new file mode 100644 index 00000000..1450dec9 --- /dev/null +++ b/docs/content/error/$compile/iscp.ngdoc @@ -0,0 +1,25 @@ +@ngdoc error +@name $compile:iscp +@fullName Invalid Isolate Scope Definition +@description + +When declaring isolate scope the scope definition object must be in specific format which starts with mode character (`@&=`) with an optional local name. + +``` +myModule.directive('directiveName', function factory() { + return { + ... + scope: { + 'attrName': '@', // OK + 'attrName2': '=localName', // OK + 'attrName3': 'name', // ERROR: missing mode @&= + 'attrName4': ' = name', // ERROR: extra spaces + 'attrName5': 'name=', // ERROR: must be prefixed with @&= + } + ... + } +}); +``` + +Please refer to the {@link ng.$compile#description_comprehensive-directive-api_directive-definition-object +`scope` option} of the directive definition documentation to learn more about the API. diff --git a/docs/content/error/$compile/multidir.ngdoc b/docs/content/error/$compile/multidir.ngdoc new file mode 100644 index 00000000..439d82c7 --- /dev/null +++ b/docs/content/error/$compile/multidir.ngdoc @@ -0,0 +1,17 @@ +@ngdoc error +@name $compile:multidir +@fullName Multiple Directive Resource Contention +@description + +This error occurs when multiple directives are applied to the same DOM element, and +processing them would result in a collision or an unsupported configuration. + + +To resolve this issue remove one of the directives which is causing the collision. + +Example scenarios of multiple incompatible directives applied to the same element include: + +* Multiple directives requesting `isolated scope`. +* Multiple directives publishing a controller under the same name. +* Multiple directives declared with the `transclusion` option. +* Multiple directives attempting to define a `template` or `templateURL`. diff --git a/docs/content/error/$compile/nodomevents.ngdoc b/docs/content/error/$compile/nodomevents.ngdoc new file mode 100644 index 00000000..ed1888c7 --- /dev/null +++ b/docs/content/error/$compile/nodomevents.ngdoc @@ -0,0 +1,20 @@ +@ngdoc error +@name $compile:nodomevents +@fullName Interpolated Event Attributes +@description + +This error occurs when one tries to create a binding for event handler attributes like `onclick`, `onload`, `onsubmit`, etc. + +There is no practical value in binding to these attributes and doing so only exposes your application to security vulnerabilities like XSS. +For these reasons binding to event handler attributes (all attributes that start with `on` and `formaction` attribute) is not supported. + + +An example code that would allow XSS vulnerability by evaluating user input in the window context could look like this: +``` +<input ng-model="username"> +<div onclick="{{username}}">click me</div> +``` + +Since the `onclick` evaluates the value as JavaScript code in the window context, setting the `username` model to a value like `javascript:alert('PWND')` would result in script injection when the `div` is clicked. + + diff --git a/docs/content/error/$compile/nonassign.ngdoc b/docs/content/error/$compile/nonassign.ngdoc new file mode 100644 index 00000000..3a7d996b --- /dev/null +++ b/docs/content/error/$compile/nonassign.ngdoc @@ -0,0 +1,41 @@ +@ngdoc error +@name $compile:nonassign +@fullName Non-Assignable Expression +@description + +This error occurs when a directive defines an isolate scope property +(using the `=` mode in the {@link ng.$compile#description_comprehensive-directive-api_directive-definition-object +`scope` option} of a directive definition) but the directive is used with an expression that is not-assignable. + +In order for the two-way data-binding to work, it must be possible to write new values back into the path defined with the expression. + +For example, given a directive: + +``` +myModule.directive('myDirective', function factory() { + return { + ... + scope: { + 'bind': '=localValue' + } + ... + } +}); +``` + +Following are invalid uses of this directive: +``` +<!-- ERROR because `1+2=localValue` is an invalid statement --> +<my-directive bind="1+2"> + +<!-- ERROR because `myFn()=localValue` is an invalid statement --> +<my-directive bind="myFn()"> +``` + + +To resolve this error, always use path expressions with scope properties that are two-way data-bound: +``` +<my-directive bind="some.property"> +<my-directive bind="some[3]['property']"> +``` + diff --git a/docs/content/error/$compile/selmulti.ngdoc b/docs/content/error/$compile/selmulti.ngdoc new file mode 100644 index 00000000..51221ad8 --- /dev/null +++ b/docs/content/error/$compile/selmulti.ngdoc @@ -0,0 +1,20 @@ +@ngdoc error +@name $compile:selmulti +@fullName Binding to Multiple Attribute +@description + +Binding to the `multiple` attribute of `select` element is not supported since switching between multiple and single mode changes the {@link ng.directive:ngModel `ngModel`} object type from instance to array of instances which breaks the model semantics. + +If you need to use different types of `select` elements in your template based on some variable, please use {@link ng.directive:ngIf ngIf} or {@link ng.directive:ngSwitch ngSwitch} directives to select one of them to be used at runtime. + + +Example with invalid usage: +``` +<select ng-model="some.model" multiple="{{mode}}"></select> +``` + +Example that uses ngIf to pick one of the `select` elements based on a variable: +``` +<select ng-if="mode == 'multiple'" ng-model="some.model" multiple></select> +<select ng-if="mode != 'multiple'" ng-model="some.model"></select> +``` diff --git a/docs/content/error/$compile/tpload.ngdoc b/docs/content/error/$compile/tpload.ngdoc new file mode 100644 index 00000000..b2b4fb2d --- /dev/null +++ b/docs/content/error/$compile/tpload.ngdoc @@ -0,0 +1,11 @@ +@ngdoc error +@name $compile:tpload +@fullName Error Loading Template +@description + +This error occurs when {@link ng.$compile `$compile`} attempts to fetch a template from some URL, and the request fails. + +To resolve this error, ensure that the URL of the template is spelled correctly and resolves to correct absolute URL. +The [Chrome Developer Tools](https://developers.google.com/chrome-developer-tools/docs/network#network_panel_overview) might also be helpful in determining why the request failed. + +If you are using {@link ng.$templateCache} to pre-load templates, ensure that the cache was populated with the template. diff --git a/docs/content/error/$compile/tplrt.ngdoc b/docs/content/error/$compile/tplrt.ngdoc new file mode 100644 index 00000000..3c29dbdc --- /dev/null +++ b/docs/content/error/$compile/tplrt.ngdoc @@ -0,0 +1,39 @@ +@ngdoc error +@name $compile:tplrt +@fullName Invalid Template Root +@description + +When a directive is declared with `template` (or `templateUrl`) and `replace` mode on, the template +must have exactly one root element. That is, the text of the template property or the content +referenced by the templateUrl must be contained within a single html element. +For example, `<p>blah <em>blah</em> blah</p>` instead of simply `blah <em>blah</em> blah`. +Otherwise, the replacement operation would result in a single element (the directive) being replaced +with multiple elements or nodes, which is unsupported and not commonly needed in practice. + + +For example a directive with definition: + +``` +myModule.directive('myDirective', function factory() { + return { + ... + replace: true, + templateUrl: 'someUrl' + ... + } +}); +``` + +And a template provided at URL `someUrl`. The template must be an html fragment that has only a +single root element, like the `div` element in this template: + +``` +<div><b>Hello</b> World!</div> +``` + +An an invalid template to be used with this directive is one that defines multiple root nodes or +elements. For example: + +``` +<b>Hello</b> World! +``` diff --git a/docs/content/error/$compile/uterdir.ngdoc b/docs/content/error/$compile/uterdir.ngdoc new file mode 100644 index 00000000..c1f263f9 --- /dev/null +++ b/docs/content/error/$compile/uterdir.ngdoc @@ -0,0 +1,34 @@ +@ngdoc error +@name $compile:uterdir +@fullName Unterminated Directive +@description + +This error occurs when using multi-element directives and a `directive-start` attribute fails to form a matching pair with a corresponding `directive-end` attribute. +A `directive-start` should have a matching `directive-end` on a sibling node in the DOM. For instance, + +``` +<table> + <tr ng-repeat-start="item in list">I get repeated</tr> + <tr ng-repeat-end>I also get repeated</tr> +</table> +``` + +is a valid example. + +This error can occur in several different ways. One is by leaving out the `directive-end` attribute, like so: + +``` +<div> + <span foo-start></span> +</div> +``` + +Another is by nesting a `directive-end` inside of `directive-start`, or vice versa: + +``` +<div> + <span foo-start><span foo-end></span></span> +</div> +``` + +To avoid this error, make sure each `directive-start` you use has a matching `directive-end` on a sibling node in the DOM. |
