AngularJS -$compileProvider.preAssignBindingsEnabled is not a function

后端 未结 2 956
谎友^
谎友^ 2021-01-21 01:46

I\'m getting the following error message when attempting to do a gulp serve on my AngularJS (ver 1.6.10) app:

Error: [$injector:modulerr] Failed to          


        
相关标签:
2条回答
  • 2021-01-21 02:32

    The $compileProvider.preAssignBindingsEnabled flag is deprecated in AngularJS V1.6 and has been removed from AngularJS V1.7.

    The AngularJS team strongly recommends migrating your applications to not rely on it as soon as possible. AngularJS V1.6 went end-of-life on 1July2018.

    From the Docs:

    Due to 38f8c9, directive bindings are no longer available in the constructor.

    Previously, the $compileProvider.preAssignBindingsEnabled flag was supported. The flag controlled whether bindings were available inside the controller constructor or only in the $onInit hook. The bindings are now no longer available in the constructor.

    To migrate your code:

    • If you specified $compileProvider.preAssignBindingsEnabled(true) you need to first migrate your code so that the flag can be flipped to false. The instructions on how to do that are available in the "Migrating from 1.5 to 1.6" guide. Afterwards, remove the $compileProvider.preAssignBindingsEnabled(true) statement.

    — AngularJS Developer Guide - Migrating to V1.7 - Compile

    From the Docs:

    Due to bcd0d4, pre-assigning bindings on component/directive controller instances is disabled by default, which means that they will no longer be available inside the constructors. It is still possible to turn it back on, which should help during the migration. Pre-assigning bindings has been deprecated and will be removed in a future version, so we strongly recommend migrating your applications to not rely on it as soon as possible.

    Initialization logic that relies on bindings being present should be put in the controller's $onInit() method, which is guaranteed to always be called after the bindings have been assigned.

    — AngularJS Developer Guide - Migrating to 1.6 - Compile

    Note:

    On 1July2018, support for AngularJS 1.6 ended. For more information, see AngularJS MISC - Version Support Status.

    0 讨论(0)
  • 2021-01-21 02:37

    It is not supported anymore since AngularJS 1.6. For people who are still migrating their application to a more recent version of AngularJs, If you specified $compileProvider.preAssignBindingsEnabled(true) you need to first migrate your code so that the flag can be flipped to false. and take a look to this guide https://docs.angularjs.org/guide/migration#migrating-from-1-5-to-1-6

    AngularJs commit reference: https://github.com/angular/angular.js/commit/38f8c97af74649ce224b6dd45f433cc665acfbfb

    0 讨论(0)
提交回复
热议问题