capybara-angular icon indicating copy to clipboard operation
capybara-angular copied to clipboard

Manual bootstrapping angular not supported

Open alex-hall opened this issue 8 years ago • 3 comments

As per Angular 2 documentation:

Pure Angular 1 applications can be bootstrapped in two ways: By using an ng-app directive 
somewhere on the HTML page, or by calling angular.bootstrap from JavaScript. In Angular 2, only 
the second method is possible - there is no ng-app in Angular 2. This is also the case for hybrid 
applications. Therefore, it is a good preliminary step to switch Angular 1 applications to use the 
JavaScript bootstrap method even before switching them to hybrid mode.

So in order to get this gem working with Angular 2 or even hybrid ng-upgrade apps, ng-app can no longer be required.

The protractor documentation solved this problem in a similar way to how the gem has solved it, so only minor updates are required.

I have already forked the gem and made the change here: #33

alex-hall avatar Jan 20 '17 21:01 alex-hall

@wrozka Some coworkers brought up the fact that this solution ONLY works if you use ng-app on the body tag. Note that this is the recommendation on the angular docs, but could potentially be considered a regression.

A safer change might be to grep for $('[ng-app]') first, then fall through to $('body') if that tag is not found. If you care about this backwards compatibility let me know, i'll create another/update the pull request.

alex-hall avatar Jan 24 '17 21:01 alex-hall

Thanks for spotting that, I missed that, please update the pull request if you can.

wrozka avatar Jan 25 '17 08:01 wrozka

I'll do this today.

alex-hall avatar Jan 25 '17 14:01 alex-hall