Commit Graph

4775 Commits

Author SHA1 Message Date
Shahar Talmi
562c4e424b fix($compile): set $isolateScope correctly for sync template directives
All isolated scope directives that do not have `templateUrl` were marked
as `$isolateScopeNoTemplate` even if they did have a `template` attribute.

This caused `jqLite#scope()` to return the wrong value for child elements
within the directive's template.

Closes #6942
v1.3.0-beta.8
2014-05-09 14:42:26 +01:00
Shahar Talmi
a0ae07bd4e feat(FormController): commit $viewValue of all child controls when form is submitted
Use the new `NgModelController.$commitViewValue()` method to commit the
`$viewValue` on all the child controls (including nested `ngForm`s) when the form
receives the `submit` event. This will happen immediately, overriding any
`updateOn` and `debounce` settings from `ngModelOptions`.

If you wish to access the committed `$modelValue`s then you can use the `ngSubmit`
directive to provide a handler.  Don't use `ngClick` on the submit button, as this
handler would be called before the pending `$viewValue`s have been committed.

Closes #7017
2014-05-09 11:50:00 +01:00
Shahar Talmi
adfc322b04 refactor(ngModelOptions): move debounce and updateOn logic into NgModelController
Move responsibility for pending and debouncing model updates into `NgModelController`.
Now input directives are only responsible for capturing changes to the input element's
value and then calling `$setViewValue` with the new value.

Calls to `$setViewValue(value)` change the `$viewValue` property but these changes are
not committed to the `$modelValue` until an `updateOn` trigger occurs (and any related
`debounce` has resolved).

The `$$lastCommittedViewValue` is now stored when `$setViewValue(value)` updates
the `$viewValue`, which allows the view to be "reset" by calling `$rollbackViewValue()`.

The new `$commitViewValue()` method allows developers to force the `$viewValue` to be
committed through to the `$modelValue` immediately, ignoring `updateOn` triggers and
`debounce` delays.

BREAKING CHANGE:

This commit changes the API on `NgModelController`, both semantically and
in terms of adding and renaming methods.

* `$setViewValue(value)` -
This method still changes the `$viewValue` but does not immediately commit this
change through to the `$modelValue` as it did previously.
Now the value is committed only when a trigger specified in an associated
`ngModelOptions` directive occurs. If `ngModelOptions` also has a `debounce` delay
specified for the trigger then the change will also be debounced before being
committed.
In most cases this should not have a significant impact on how `NgModelController`
is used: If `updateOn` includes `default` then `$setViewValue` will trigger
a (potentially debounced) commit immediately.
* `$cancelUpdate()` - is renamed to `$rollbackViewValue()` and has the same meaning,
which is to revert the current `$viewValue` back to the `$lastCommittedViewValue`,
to cancel any pending debounced updates and to re-render the input.

To migrate code that used `$cancelUpdate()` follow the example below:

Before:

```
  $scope.resetWithCancel = function (e) {
    if (e.keyCode == 27) {
      $scope.myForm.myInput1.$cancelUpdate();
      $scope.myValue = '';
    }
  };
```

After:

```
  $scope.resetWithCancel = function (e) {
    if (e.keyCode == 27) {
      $scope.myForm.myInput1.$rollbackViewValue();
      $scope.myValue = '';
    }
  }
```
2014-05-09 11:41:38 +01:00
Shahar Talmi
0ef17276e9 refactor(inputSpec): move call to $digest into compileInput helper
It is reasonable to expect a digest to occur between an input element
compiling and the first user interaction.  Rather than add digests to
each test this change moves it into the `compileInput` helper function.
2014-05-09 09:56:27 +01:00
Caitlin Potter
ac37915ef6 fix(ngSwitch): properly support case labels with different numbers of transclude fns
Due to a regression introduced several releases ago, the ability for multiple transclude functions
to work correctly changed, as they would break if different case labels had different numbers of
transclude functions.

This CL corrects this by not assuming that previous elements and scope count have the same length.

Fixes #7372
Closes #7373
2014-05-08 17:08:04 -04:00
Richard Littauer
6593d83626 docs(CONTRIBUTING.md): grammar and link fixes
Fix dev-doc link, grammatical error.

Closes #7275
2014-05-08 18:05:52 +02:00
Chris Rose
7700024ef5 docs(CONTRIBUTING.md): anachor fix
Closes #7294
2014-05-08 11:26:44 +02:00
sap9433
4899e781ff docs(CONTRIBUTING.md): anchor fix
"Follow our Coding Rules" should link to "#rules" and not "#coding-rules"

Closes #7349
2014-05-08 11:12:58 +02:00
Joe Pettersson
28af74a901 docs(dateFilter): correct example for date 'fullDate filter'
The equivalent expanded example for 'fullDate' is given as 'EEEE, MMMM d,y'
whereas it should be 'EEEE, MMMM d, y'. With added whitespace.

Closes #7350
2014-05-08 10:53:34 +02:00
Taylor Hutchison
88335fdfcf docs(ngCookies): correct arguments in $cookieStore example
Closes #7390
2014-05-08 10:29:28 +02:00
mjfroehlich
72d63dbcc0 docs(Scope): fix typo in a link
Closes #7389
2014-05-08 10:23:03 +02:00
Thomas Tuts
055b738d4e docs(directive): fix misspelled HTML class for an alert
Muchas gracias

Closes #7381
2014-05-07 07:59:18 -04:00
Matias Niemelä
2faa4781c5 docs(NgMessages): fix up links and headings 2014-05-07 00:52:25 -04:00
barcahead
6f9bcd3307 docs($rootScope): use unshift to add items to the array at the beginning
Closes #7364
2014-05-06 21:29:30 -04:00
Mathew Foscarini
e16e7df689 docs(minErr): small grammar fix for $compileMinErr ctreq
Closes #7365
2014-05-06 21:26:31 -04:00
Caitlin Potter
2972de8a44 chore(travis): run protractor tests with ff28
FirefoxDriver seems to have an issue with FF29 which is breaking a test case, and causing false negatives.

There is an issue opened on protractor regarding this at https://github.com/angular/protractor/issues/784

Closes #7369
2014-05-06 18:56:44 -04:00
Peter Bacon Darwin
e0e9ccdb79 docs(tutorial): move bower_components into app folder 2014-05-05 20:54:07 +01:00
Jamie Krug
3f540e3d8a docs(tutorial/step-07): fix typo in route pattern
One instance of `/phones/:phoneId` erroneously had a singular version,
`/phone/:phoneId`, which does not match what was actually used in the code.

Closes #7313
2014-05-04 20:52:59 +01:00
Jack Hsu
8b91aa64b7 docs(directives): fix code lang matching
Closes #7339
2014-05-04 20:46:38 +01:00
spacemigas
1c0241e5b2 docs($interpolate): fix bug in example
Closes #7342
2014-05-04 20:37:34 +01:00
Joel Hooks
c56e32a7fa fix(ngModelOptions): enable overriding the default with a debounce of zero
Because of how the logic was set up, a value of `0` was assumed to be the
same as `undefined`, which meant that you couldn't override the default
debounce delay with a value of zero.

For example, the following assigned a debounce delay of 500ms to the `blur`
event.

```
ngModelOptions="{ updateOn: 'default blur', debounce: {'default': 500, 'blur':
0} }"
```

Closes #7205
2014-05-04 20:18:27 +01:00
Peter Bacon Darwin
8c08fcfb1b test(ngModelOptions): fix e2e test focussing 2014-05-04 20:07:07 +01:00
Shahar Talmi
fbf5ab8f17 fix(ngModelOptions): initialize ngModelOptions in prelink
Input controls require `ngModel` which in turn brings in the `ngModelOptions`
but since ngModel does this initialization in the post link function, the
order in which the directives are run is relevant.

Directives are sorted by priority and name but `ngModel`, `input` and `textarea`
have the same priority. It just happens that `textarea` is alphabetically
sorted and so linked before `ngModel` (unlike `input`).

This is a problem since inputs expect `ngModelController.$options`
to exist at post-link time and for `textarea` this has not happened.

This is solved easily by moving the initialization of `ngModel` to the
pre-link function.

Closes #7281
Closes #7292
2014-05-04 20:07:07 +01:00
raghudodda
e395170eef docs(ngModelOptions): correct typo
Closes #7335
2014-05-04 18:59:12 +01:00
Yutaka Yamaguchi
627b0354ec fix(ngSanitize): encode surrogate pair properly
The encodeEndities function encode non-alphanumeric characters to entities with charCodeAt.
charCodeAt does not return one value when their unicode codeponts is higher than 65,356.
It returns surrogate pair, and this is why the Emoji which has higher codepoints is garbled.
We need to handle them properly.

Closes #5088
Closes #6911
2014-05-02 17:48:57 -04:00
Brian Ford
8d18038301 fix(ngSrc, ngSrcset): only interpolate if all expressions are defined
BREAKING CHANGE

If `bar` is `undefined`, before `<img src="foo/{{bar}}.jpg">` yields
`<img src="foo/.jpg">`. With this change, the binding will not set `src`.

If you want the old behavior, you can do this: `<img src="foo/{{bar || ''}}.jpg">`.

The same applies for `srcset` as well.

Closes #6984
2014-05-02 14:06:57 -07:00
Brian Ford
c2362e3f45 feat($interpolate): add optional allOrNothing param 2014-05-02 14:06:57 -07:00
Peter Bacon Darwin
2b6c2c5fbd docs(Attributes): ensure code sample is not escaped
Closes #6649
2014-05-02 21:49:15 +01:00
Matias Niemelä
0f4016c84a feat(NgMessages): introduce the NgMessages module and directives
The ngMessages module provides directives designed to better support
handling and reusing error messages within forms without the need to
rely on complex structural directives.

Please note that the API for ngMessages is experimental and may possibly change with
future releases.
2014-05-02 16:31:34 -04:00
Caitlin Potter
c0b4e2db9c fix(injector): invoke config blocks for module after all providers
This change ensures that a module's config blocks are always invoked after all of its providers are
registered.

BREAKING CHANGE:

Previously, config blocks would be able to control behaviour of provider registration, due to being
invoked prior to provider registration. Now, provider registration always occurs prior to configuration
for a given module, and therefore config blocks are not able to have any control over a providers
registration.

Example:

Previously, the following:

   angular.module('foo', [])
     .provider('$rootProvider', function() {
       this.$get = function() { ... }
     })
     .config(function($rootProvider) {
       $rootProvider.dependentMode = "B";
     })
     .provider('$dependentProvider', function($rootProvider) {
       if ($rootProvider.dependentMode === "A") {
         this.$get = function() {
           // Special mode!
         }
       } else {
         this.$get = function() {
           // something else
         }
       }
     });

would have "worked", meaning behaviour of the config block between the registration of "$rootProvider"
and "$dependentProvider" would have actually accomplished something and changed the behaviour of the
app. This is no longer possible within a single module.

Fixes #7139
Closes #7147
2014-05-02 14:12:22 -04:00
Caitlin Potter
924ee6db06 fix($interpolate): don't ReferenceError when context is undefined
546cb42 introduced a regression, which would cause the function returned from
$interpolate to throw a ReferenceError if `context` is undefined. This change
prevents the error from being thrown.

Closes #7230
Closes #7237
2014-05-02 13:58:13 -04:00
Peter Bacon Darwin
cbc7496c1f chore(doc-gen): update to dgeni 0.3.0 2014-05-02 14:48:45 +01:00
Chris Rose
69d96e8b71 docs($injector): fix typos 2014-05-01 15:35:58 -07:00
mjfroehlich
b426424e63 docs(guide/providers): minor edits 2014-05-01 14:39:55 -07:00
Dave Smith
e1d6178457 fix($httpBackend): Add missing expectHEAD() method
This was documented but not implemented.

With accompanying unit test to ensure the $httpBackend.expect*() methods exist.

Closes #7320
2014-04-30 18:51:20 -04:00
Janas Page
3fb2d2ac3b docs($anchorScroll): minor copyedit.
Singular-tense verb. Definite article.

Closes #7319
2014-04-30 17:49:28 -04:00
Brian Ford
e0d4c42148 chore(package.json): add qq
e0375a61d0 removed qq, but the changelog script still needs it
2014-04-30 14:02:58 -07:00
Caitlin Potter
ad4336f935 chore($http): remove deprecated responseInterceptors functionality
Code cleanup! response interceptors have been deprecated for some time, and it is confusing to have
two APIs, one of which is slightly "hidden" and hard to see, which perform the same task. The newer
API is a bit cleaner and more visible, so this is naturally preferred.

BREAKING CHANGE:

Previously, it was possible to register a response interceptor like so:

    // register the interceptor as a service
    $provide.factory('myHttpInterceptor', function($q, dependency1, dependency2) {
      return function(promise) {
        return promise.then(function(response) {
          // do something on success
          return response;
        }, function(response) {
          // do something on error
          if (canRecover(response)) {
            return responseOrNewPromise
          }
          return $q.reject(response);
        });
      }
    });

    $httpProvider.responseInterceptors.push('myHttpInterceptor');

Now, one must use the newer API introduced in v1.1.4 (4ae46814), like so:

    $provide.factory('myHttpInterceptor', function($q) {
      return {
        response: function(response) {
          // do something on success
          return response;
        },
        responseError: function(response) {
          // do something on error
          if (canRecover(response)) {
            return responseOrNewPromise
          }
          return $q.reject(response);
        }
      };
    });

    $httpProvider.interceptors.push('myHttpInterceptor');

More details on the new interceptors API (which has been around as of v1.1.4) can be found at
https://docs.angularjs.org/api/ng/service/$http#interceptors

Closes #7266
Closes #7267
2014-04-30 17:00:52 -04:00
Vojta Jina
81147a8bfd chore(travis): disable captureTimeout
All of the recent failures were caused by too much load on SL, not
an actual problem.

I think a proper solution will be:
https://github.com/karma-runner/karma-sauce-launcher/issues/37
2014-04-30 15:21:48 +02:00
Peter Bacon Darwin
82751f5960 chore(travis-build): don't re-package when testing docs
Since .travis is already running `grunt package` in the `before_script`
block there is no need to run it again when testing the docs.
2014-04-30 11:16:21 +01:00
Peter Bacon Darwin
8b8992b145 revert: test(ngModelOptions): ensure input has focus in e2e tests
This reverts commit 8d38ec3892.
The protractor tests for ng-model-options were failing locally on Chrome
for me but this commit breaks the tests on Firefox.
2014-04-30 11:01:02 +01:00
Brian Ford
60b2851df7 chore(travis): use npm cache 2014-04-29 15:25:00 -07:00
Caitlin Potter
f0e12ea7fe feat($compile): allow SVG and MathML templates via special type property
Previously, templates would always be assumed to be valid HTML nodes. In some cases, it is
desirable to use SVG or MathML or some other language.

For the time being, this change is only truly meaningful for SVG elements, as MathML has
very limited browser support. But in the future, who knows?

Closes #7265
2014-04-29 14:48:50 -04:00
Vojta Jina
28ef2637c1 chore(travis): update Chrome on SL to 34
For some reason, SL gives us Chrome 28 when no version is specified.
2014-04-29 15:56:37 +02:00
Peter Bacon Darwin
8d38ec3892 test(ngModelOptions): ensure input has focus in e2e tests
This was not failing on Travis or Jenkins but was reliably failing on my
local build.
2014-04-29 13:29:01 +01:00
Peter Bacon Darwin
8e404c4dc1 docs(directives): remove line numbers from code blocks 2014-04-29 12:33:20 +01:00
Brian Ford
7570e9f07d docs($sce): fix grammar 2014-04-28 23:53:37 -07:00
Peter Bacon Darwin
d90f83cda8 docs(examples): don't attempt to convert example content from JSON
There are some files in the examples that look like JSON and the default
$http transformResponse handler was trying to convert these from strings
to object. An example was the style.css file in the
https://docs.angularjs.org/api/ng/type/ngModel.NgModelController docs.

This commit fixes this by simply removing this transform when loading
these files.
2014-04-28 22:18:55 +01:00
Uri Goldshtein
fcc3a7a423 docs(guide): add another analytics library 2014-04-28 12:04:06 -07:00
Edward Brey
e3814b1266 docs(angular.Module): add link to module.config() docs
Add a link on where to find more info about how to use `module.config()`

Closes #6270
2014-04-28 15:05:40 +01:00