angular.io icon indicating copy to clipboard operation
angular.io copied to clipboard

StyleGuide - Limit the usage of forwardRef

Open johnpapa opened this issue 9 years ago • 3 comments

To be discussed ...

I copied several of these from early discussions and will list them as issues for future discussion after ngConf

cc // @mgechev @wardbell

  • Limit the usage of forwardRef.

    Why?: The usage of forwardRef indicates either a cyclic dependency or inconsistency in the services' declaration (i.e. the dependent service is declared before its dependency). In both cases there is usually a better approach to be used.

johnpapa avatar Apr 24 '16 19:04 johnpapa

One place where forwardRef seems necessary is when components need to provide value accessors, e.g. for custom form controls. An example can be found in md-checkbox which provides a ControlValueAccessor so it can be used similar to a native checkbox. I'm not sure if there's been a better solution implemented since this code was written though.

traviskaufman avatar May 06 '16 21:05 traviskaufman

Hi guys. Has anybody come up with how to make custom form controls without using forwardRef?

opporancisis avatar May 08 '17 04:05 opporancisis

No solution here with Angular 4. @opporancisis did you find one?

meriturva avatar Jun 28 '17 13:06 meriturva