You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
Copy file name to clipboardExpand all lines: docs/content/guide/migration.ngdoc
+37
Original file line number
Diff line number
Diff line change
@@ -48,6 +48,7 @@ below should still apply, but you may want to consult the
48
48
<li>{@link guide/migration#underscore-prefixed/suffixed-properties-are-non-bindable Underscore-prefixed/suffixed properties are non-bindable}</li>
49
49
<li>{@link guide/migration#you-cannot-bind-to-select[multiple] You cannot bind to select[multiple]}</li>
50
50
<li>{@link guide/migration#uncommon-region-specific-local-files-were-removed-from-i18n Uncommon region-specific local files were removed from i18n}</li>
51
+
<li>{@link guide/migration#services-can-now-return-functions Services can now return functions}</li>
51
52
</ul>
52
53
53
54
@@ -653,3 +654,39 @@ load and use your copy of the locale file provided that you maintain it yourself
653
654
654
655
See [6382e21f](https://github.com/angular/angular.js/commit/6382e21fb28541a2484ac1a241d41cf9fbbe9d2c).
655
656
657
+
## Services can now return functions
658
+
659
+
Previously, the service constructor only returned objects regardless of whether a function was returned.
660
+
661
+
Now, `$injector.instantiate` (and thus `$provide.service`) behaves the same as the native
662
+
`new` operator and allows functions to be returned as a service.
663
+
664
+
If using a JavaScript preprocessor it's quite possible when upgrading that services could start behaving incorrectly.
665
+
Make sure your services return the correct type wanted.
666
+
667
+
**Coffeescript example**
668
+
669
+
```
670
+
myApp.service 'applicationSrvc', ->
671
+
@something = "value"
672
+
@someFunct = ->
673
+
"something else"
674
+
```
675
+
676
+
pre 1.2 this service would return the whole object as the service.
677
+
678
+
post 1.2 this service returns `someFunct` as the value of the service
679
+
680
+
you would need to change this services to
681
+
682
+
```
683
+
myApp.service 'applicationSrvc', ->
684
+
@something = "value"
685
+
@someFunct = ->
686
+
"something else"
687
+
return
688
+
```
689
+
690
+
to continue to return the complete instance.
691
+
692
+
See [c22adbf1](https://github.com/angular/angular.js/commit/c22adbf160f32c1839fbb35382b7a8c6bcec2927).
0 commit comments