I have a project build with Angular 1.5, with the 1.6 update the Angular team decided to disable pre-assigning controller bindings by default and if you want to enable them then you need to do: $compileProvider.preAssignBindingsEnabled(true);
This is not much of a problem with the application itself, all I need to do is add a config statement which uses $compileProvider
.config(function($compileProvider){
$compileProvider.preAssignBindingsEnabled(true);
})
But when it comes to testing I've run into a snag. I have many modules, none of which use a config
.
And I have tests which pull in all my modules and run something like this:
beforeEach(function () {
module('myModule');
inject(function ($injector) {
$rootScope = $injector.get('$rootScope');
$compile = $injector.get('$compile');
});
// do stuff, run tests
});
These tests all fail now. The simple fix for this is to either add a config to ALL my modules and have compileProvider run on all those or to do something like this:
// myModule1.spec.js
beforeEach(function () {
module('myModule', function ($compileProvider) {
$compileProvider.preAssignBindingsEnabled(true);
});
...
});
// myModule2.spec.js
beforeEach(function () {
module('myModule2', function ($compileProvider) {
$compileProvider.preAssignBindingsEnabled(true);
});
...
});
// myModule3.spec.js
beforeEach(function () {
module('myModule3', function ($compileProvider) {
$compileProvider.preAssignBindingsEnabled(true);
});
...
});
But the problem is I have just under a hundred components and would like to just set this in one place globally.
How could I do that? Is it possible?
Aucun commentaire:
Enregistrer un commentaire