Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TemplateCompiler issue with NgModel and <select> #5838

Closed
jakemac53 opened this issue Dec 11, 2015 · 10 comments
Closed

TemplateCompiler issue with NgModel and <select> #5838

jakemac53 opened this issue Dec 11, 2015 · 10 comments
Assignees
Labels
effort1: hours refactoring Issue that involves refactoring or code-cleanup

Comments

@jakemac53
Copy link
Contributor

Repro here https://github.com/jakemac53/ng2-template-compiler-repro

It works fine in the mirrors based version but the compiled version fails with EXCEPTION: No value accessor for '' in [AST]

@vicb
Copy link
Contributor

vicb commented Dec 11, 2015

What are the steps to trigger the issue ? (can't reproduce)

@jakemac53
Copy link
Contributor Author

  • clone the repo
  • run pub get
  • run pub serve
  • load up localhost:8080 in dartium or chrome

@vicb
Copy link
Contributor

vicb commented Dec 11, 2015

That's what I did...

What env/os are you testing with ?

@vicb
Copy link
Contributor

vicb commented Dec 11, 2015

Could you add the full stack trace to the report ?

@jakemac53
Copy link
Contributor Author

I am running on goobuntu, but it is also affecting osx as well.

Uncaught Unhandled exception:
EXCEPTION: No value accessor for '' in [AST]
ORIGINAL EXCEPTION: No value accessor for ''
ORIGINAL STACKTRACE:
#0      _throwError (package:angular2/src/common/forms/directives/shared.dart:57:3)
#1      setUpControl (package:angular2/src/common/forms/directives/shared.dart:30:35)
#2      NgModel.ngOnChanges (package:angular2/src/common/forms/directives/ng_model.dart:80:7)
#3      _NgModelRepro_0.detectChangesInRecordsInternal (http://localhost:8080/index.template.dart:45:65)
#4      AbstractChangeDetector.detectChangesInRecords (package:angular2/src/core/change_detection/abstract_change_detector.dart:141:12)
#5      AbstractChangeDetector.runDetectChanges (package:angular2/src/core/change_detection/abstract_change_detector.dart:115:10)
#6      AbstractChangeDetector._detectChangesInViewChildren (package:angular2/src/core/change_detection/abstract_change_detector.dart:224:12)
#7      AbstractChangeDetector.runDetectChanges (package:angular2/src/core/change_detection/abstract_change_detector.dart:118:10)
#8      AbstractChangeDetector.detectChanges (package:angular2/src/core/change_detection/abstract_change_detector.dart:101:10)
#9      ChangeDetectorRef_.detectChanges (package:angular2/src/core/change_detection/change_detector_ref.dart:209:14)
#10     ApplicationRef_.tick.<anonymous closure> (package:angular2/src/core/application_ref.dart:484:63)
#11     List.forEach (dart:core-patch/growable_array.dart:233)
#12     ApplicationRef_.tick (package:angular2/src/core/application_ref.dart:484:32)
#13     ApplicationRef_._loadComponent (package:angular2/src/core/application_ref.dart:454:10)
#14     ApplicationRef_.bootstrap.<anonymous closure>.<anonymous closure> (package:angular2/src/core/application_ref.dart:426:16)
#15     StackZoneSpecification.registerUnaryCallback.<anonymous closure>.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:134:26)
#16     StackZoneSpecification._run (package:stack_trace/src/stack_zone_specification.dart:205:15)
#17     StackZoneSpecification.registerUnaryCallback.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:134:14)
#18     NgZone._runUnary.<anonymous closure> (package:angular2/src/core/zone/ng_zone.dart:321:40)
#19     _rootRun (dart:async/zone.dart:903)
#20     _ZoneDelegate.run (dart:async/zone.dart:502)
#21     NgZone._run (package:angular2/src/core/zone/ng_zone.dart:291:21)
#22     NgZone._runUnary (package:angular2/src/core/zone/ng_zone.dart:321:7)
#23     _CustomZone.runUnary (dart:async/zone.dart:810)
#24     _Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:502)
#25     _Future._propagateToListeners (dart:async/future_impl.dart:585)
#26     _Future._completeWithValue (dart:async/future_impl.dart:376)
#27     _Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:430)
#28     NgZone._scheduleMicrotask.<anonymous closure> (package:angular2/src/core/zone/ng_zone.dart:331:11)
#29     StackZoneSpecification._run (package:stack_trace/src/stack_zone_specification.dart:205:15)
#30     StackZoneSpecification.registerCallback.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:124:48)
#31     _rootRun (dart:async/zone.dart:907)
#32     _ZoneDelegate.run (dart:async/zone.dart:502)
#33     NgZone._run (package:angular2/src/core/zone/ng_zone.dart:291:21)
#34     _CustomZone.run (dart:async/zone.dart:802)
#35     _CustomZone.runGuarded (dart:async/zone.dart:708)
#36     _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:733)
#37     _microtaskLoop (dart:async/schedule_microtask.dart:43)
#38     _microtaskLoopEntry (dart:async/schedule_microtask.dart:52)
#39     _ScheduleImmediateHelper._handleMutation (dart:html:49298)
#40     MutationObserver._create.<anonymous closure> (dart:html:27545)

ERROR CONTEXT:
Instance of '_Context'
#0      AbstractChangeDetector._throwError (package:angular2/src/core/change_detection/abstract_change_detector.dart:350:5)
#1      AbstractChangeDetector.detectChangesInRecords (package:angular2/src/core/change_detection/abstract_change_detector.dart:147:12)
#2      AbstractChangeDetector.runDetectChanges (package:angular2/src/core/change_detection/abstract_change_detector.dart:115:10)
#3      AbstractChangeDetector._detectChangesInViewChildren (package:angular2/src/core/change_detection/abstract_change_detector.dart:224:12)
#4      AbstractChangeDetector.runDetectChanges (package:angular2/src/core/change_detection/abstract_change_detector.dart:118:10)
#5      AbstractChangeDetector.detectChanges (package:angular2/src/core/change_detection/abstract_change_detector.dart:101:10)
#6      ChangeDetectorRef_.detectChanges (package:angular2/src/core/change_detection/change_detector_ref.dart:209:14)
#7      ApplicationRef_.tick.<anonymous closure> (package:angular2/src/core/application_ref.dart:484:63)
#8      List.forEach (dart:core-patch/growable_array.dart:233)
#9      ApplicationRef_.tick (package:angular2/src/core/application_ref.dart:484:32)
#10     ApplicationRef_._loadComponent (package:angular2/src/core/application_ref.dart:454:10)
#11     ApplicationRef_.bootstrap.<anonymous closure>.<anonymous closure> (package:angular2/src/core/application_ref.dart:426:16)
#12     StackZoneSpecification.registerUnaryCallback.<anonymous closure>.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:134:26)
#13     StackZoneSpecification._run (package:stack_trace/src/stack_zone_specification.dart:205:15)
#14     StackZoneSpecification.registerUnaryCallback.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:134:14)
#15     NgZone._runUnary.<anonymous closure> (package:angular2/src/core/zone/ng_zone.dart:321:40)
#16     _rootRun (dart:async/zone.dart:903)
#17     _ZoneDelegate.run (dart:async/zone.dart:502)
#18     NgZone._run (package:angular2/src/core/zone/ng_zone.dart:291:21)
#19     NgZone._runUnary (package:angular2/src/core/zone/ng_zone.dart:321:7)
#20     _CustomZone.runUnary (dart:async/zone.dart:810)
#21     _Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:502)
#22     _Future._propagateToListeners (dart:async/future_impl.dart:585)
#23     _Future._completeWithValue (dart:async/future_impl.dart:376)
#24     _Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:430)
#25     NgZone._scheduleMicrotask.<anonymous closure> (package:angular2/src/core/zone/ng_zone.dart:331:11)
#26     StackZoneSpecification._run (package:stack_trace/src/stack_zone_specification.dart:205:15)
#27     StackZoneSpecification.registerCallback.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:124:48)
#28     _rootRun (dart:async/zone.dart:907)
#29     _ZoneDelegate.run (dart:async/zone.dart:502)
#30     NgZone._run (package:angular2/src/core/zone/ng_zone.dart:291:21)
#31     _CustomZone.run (dart:async/zone.dart:802)
#32     _CustomZone.runGuarded (dart:async/zone.dart:708)
#33     _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:733)
#34     _microtaskLoop (dart:async/schedule_microtask.dart:43)
#35     _microtaskLoopEntry (dart:async/schedule_microtask.dart:52)
#36     _ScheduleImmediateHelper._handleMutation (dart:html:49298)
#37     MutationObserver._create.<anonymous closure> (dart:html:27545)

@vicb
Copy link
Contributor

vicb commented Dec 11, 2015

Probably a missing directive (SelectControlValueAccessor), let me try

@vicb
Copy link
Contributor

vicb commented Dec 11, 2015

So yep the raison of the error is that you are missing the SelectControlValueAccessor in your code:

@Component(
    selector: 'ng-model-repro',
    template: ...,
    directives: const [NgModel, SelectControlValueAccessor])
class NgModelRepro {
  String filter = 'b';
}

However the best is probably to include FORM_DIRECTIVES whenever you using forms in a template:

@Component(
    selector: 'ng-model-repro',
    template: ...,
    directives: const [FORM_DIRECTIVES])
class NgModelRepro {
  String filter = 'b';
}

Please leave the issue opened, we should change the error message to be more descriptive

Edit: It would be nice that it works the same in dev vs prod mode

@vicb vicb added P3: important effort1: hours refactoring Issue that involves refactoring or code-cleanup labels Dec 11, 2015
@jakemac53
Copy link
Contributor Author

Sounds good, I definitely assumed that since it was working in dev mode that there was no error on my part. Also nicer errors would definitely be great.

@vsavkin
Copy link
Contributor

vsavkin commented Mar 9, 2016

Replaced this issue with #7518

@vsavkin vsavkin closed this as completed Mar 9, 2016
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
effort1: hours refactoring Issue that involves refactoring or code-cleanup
Projects
None yet
Development

No branches or pull requests

3 participants