diff options
| author | wbyoko | 2014-02-28 20:04:44 -0600 |
|---|---|---|
| committer | Brian Ford | 2014-03-17 15:06:53 -0700 |
| commit | 63ec18f5c9931c71addde56acbfd448c71db6cc0 (patch) | |
| tree | fe49a500fc88501d8d62fa0ae732dbd980c509e4 | |
| parent | e381c4dd09c3c9a2c864303f6258ca5366ac988c (diff) | |
| download | angular.js-63ec18f5c9931c71addde56acbfd448c71db6cc0.tar.bz2 | |
docs(migration): note that services can now return functions
This change mostly effects preprocessed javascript.
| -rw-r--r-- | docs/content/guide/migration.ngdoc | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/docs/content/guide/migration.ngdoc b/docs/content/guide/migration.ngdoc index 498b5345..df042582 100644 --- a/docs/content/guide/migration.ngdoc +++ b/docs/content/guide/migration.ngdoc @@ -48,6 +48,7 @@ below should still apply, but you may want to consult the <li>{@link guide/migration#underscore-prefixed/suffixed-properties-are-non-bindable Underscore-prefixed/suffixed properties are non-bindable}</li> <li>{@link guide/migration#you-cannot-bind-to-select[multiple] You cannot bind to select[multiple]}</li> <li>{@link guide/migration#uncommon-region-specific-local-files-were-removed-from-i18n Uncommon region-specific local files were removed from i18n}</li> + <li>{@link guide/migration#services-can-now-return-functions Services can now return functions}</li> </ul> @@ -653,3 +654,39 @@ load and use your copy of the locale file provided that you maintain it yourself See [6382e21f](https://github.com/angular/angular.js/commit/6382e21fb28541a2484ac1a241d41cf9fbbe9d2c). +## Services can now return functions + +Previously, the service constructor only returned objects regardless of whether a function was returned. + +Now, `$injector.instantiate` (and thus `$provide.service`) behaves the same as the native +`new` operator and allows functions to be returned as a service. + +If using a JavaScript preprocessor it's quite possible when upgrading that services could start behaving incorrectly. +Make sure your services return the correct type wanted. + +**Coffeescript example** + +``` +myApp.service 'applicationSrvc', -> + @something = "value" + @someFunct = -> + "something else" +``` + +pre 1.2 this service would return the whole object as the service. + +post 1.2 this service returns `someFunct` as the value of the service + +you would need to change this services to + +``` +myApp.service 'applicationSrvc', -> + @something = "value" + @someFunct = -> + "something else" + return +``` + +to continue to return the complete instance. + +See [c22adbf1](https://github.com/angular/angular.js/commit/c22adbf160f32c1839fbb35382b7a8c6bcec2927). |
