5

We were hit by an old breaking change in our legacy AngularJs application which we won't update to Angular >2 soon.

Since AngularJs 1.6 $compileProvider.preAssignBindingsEnabled was set to 'true' by default but up there was an option to set it to 'false'.

With AngularJs 1.7 this behaviour isn't allowed anymore.

So we have to check where we are using bindings in components/directives to use the new $onInit function which is called once all bindings are available for sure.

Since we don't use .component but .directive only:

Is it true, that we only have to apply this change for all directives which are using bindToController: true?

Or which other cases might be forced to consider?

Update for clarification:

  1. I understand that we have to change/upgrade to make it work and why.
  2. What I am not perfectly understanding (and didn't see it in the suggested duplicate either): When not using components at all, where does this change affect us? Is ot only when we directives with bindToController: true or are there others (potentially less intuitive like using $scope in a specific way/context etc.). From reading the upgrade instructions we only got the component example.
LBA
  • 3,859
  • 2
  • 21
  • 60
  • Relevant, other SO post where the answer describes migrating AngularJS versions, for reference: https://stackoverflow.com/questions/50937725/angularjs-compileprovider-preassignbindingsenabled-is-not-a-function – RoboBear Jul 10 '18 at 17:09
  • 1
    From that post "The flag controlled whether bindings were available inside the controller constructor or only in the $onInit hook." -- I think it's safe to say one of your answers (do we only have to make this update to directives bound to a controller) is therefore *yes*. – RoboBear Jul 10 '18 at 17:13
  • On 1July2018, support for AngularJS 1.6 ended. We strongly recommend migrating your applications to not rely on it as soon as possible. For more information, see [AngularJS MISC - Version Support Status](https://docs.angularjs.org/misc/version-support-status). – georgeawg Jul 10 '18 at 17:43
  • @georgeawg, kindly see my update, i don't see the duplicatr, because I understood why and how - I am specifically asking for the where. – LBA Jul 10 '18 at 17:56
  • Thanks @georgeawg, duplicate's question is about bindToController too. So nothing else to consider then? – LBA Jul 10 '18 at 18:14
  • I'm voting to keep this question closed as in addition to being answered by duplicates, the question is too broad. If those answers do not fully address your question, [please ask a new question](https://stackoverflow.com/questions/ask). Avoid asking multiple distinct questions at once. Limit the question to a problem with enough detail to identify an adequate answer. – georgeawg Jul 10 '18 at 19:25
  • I am really sorry, if it's my English or my limited understanding. There is only one question: Is it enough to deql with bindToController: true Directives? I found no other example proving me wrong so far. Can you confirm? Or how should I rephrase the questuon? – LBA Jul 10 '18 at 19:32
  • @gregawg, i guess i got it now, i rephrased summary. Again: I am not asking when and why to upgrade! – LBA Jul 10 '18 at 19:43
  • OK, created a [new question](https://stackoverflow.com/questions/51274406/upgrade-angularjs-1-5-to-1-6-which-exact-bindings-are-affected-by-change-in-c) trying to be as specific as possible. Should I delete this one? – LBA Jul 10 '18 at 21:58

0 Answers0