Breaks manually bootstrapped apps (does not return $injector)
I'm not sure how this happens, but if you open this jsbin output in a browser without the extension (or an older version) then it works just fine. If you open it with 0.5.0, it doesn't bootstrap and there's an error in the console.
This example seems to be failing for a different reason that my app, but in both cases, angular.bootstrap is returning undefined instead of $injector as it should.
I think this is actually two separate issues:
- Batarang is having trouble with
controller as - angular.bootstrap isn't returning the
$injectoras it should when batarang is installed.
- should be fixed in https://github.com/angular/angular-hint-controllers/commit/c354d2945faabcfd716a9c18ae633068cedcc475 and batarang v0.6.0.
Working on a fix for for second point
I don't know if it helps, but from the investigations we have done at my company, we found that it seems Batarang alters window.name. At least if you set a breakpoint on row 1393 in the bootstrap function in angular.js (v1.2.15), you get different values for window.name depending on whether Batarang is enabled or not. The contents of the row is if (window && !NG_DEFER_BOOTSTRAP.test(window.name)) {
With Batarang enabled: window.name = "NG_DEFER_BOOTSTRAP!"
With Batarang disabled: window.name = "" (empty)
The not empty window name makes the if-statement evaluate to false which means the doBootstrap() function never runs and consequently the $injector is never returned
@marols – thank you for including this information.
I'm aware that the issue is that deferred bootstrap doesn't return the injector as expected. Working on a fix now.
+1
- angular.bootstrap isn't returning the $injector as it should when batarang is installed.
AngularJS Batarang 0.7.4
@kentcdodds provided this JSBin repo: http://output.jsbin.com/wehufa
Just realized that the original had a jsbin as well that reproduces the issue :-)
Do we know how to fix this issue?
This appears to happen with all defers of bootstrapping, not just Batarang: http://jsbin.com/silaji/edit?html,js,output
Digging through Angular.js proper to see if there's a solution there.
From the docs:
Note that Protractor based end-to-end tests cannot use this function to bootstrap manually. They must use ngApp.
Batarang uses the same techniques as Protractor, so this is a limitation of Angular itself. Sorry about that folks...
Huh... That explains why my protractor tests act funny sometimes :-) I think that I'll have to rewrite my bootstrap to do something like this then. :-( Thanks for the tip!
@kentcdodds still does not work for me with Meteor. It seems to be closed there too as a limitation https://github.com/Urigo/angular-meteor/issues/90