When to use the AngularJS `$onInit` Life-Cycle Hook
问题 With the release of AngularJS V1.7, the option to pre-assign bindings to has deprecated and removed: Due to 38f8c9, directive bindings are 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