Repository: angular
Issue: Preload modules modules based on canLoad guard result
Labels: feature,freq2: medium,area: router,router: lazy loading,feature: insufficient votes,feature: votes required

<!--
PLEASE HELP US PROCESS GITHUB ISSUES FASTER BY PROVIDING THE FOLLOWING INFORMATION.

ISSUES MISSING IMPORTANT INFORMATION MAY BE CLOSED WITHOUT INVESTIGATION.
-->

## I'm submitting a...
<!-- Check one of the following options with "x" -->
<pre><code>
[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  <!-- Please search GitHub for a similar issue or PR before submitting -->
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
</code></pre>

## Current behavior
<!-- Describe how the issue manifests. -->
Currently, when using a preloadering strategy (like `PreloadAllModules`), the preloader does not process routes with a `canLoad` property and therefore does not preload them. There is no indication in the [`CanLoad` interface documentation](https://angular.io/api/router/CanLoad) that this will happen.

https://github.com/angular/angular/blob/0f5c70d563b6943623a5940036a52fe077ad3fac/packages/router/src/router_preloader.ts#L112-L114

The [router guide](https://angular.io/guide/router#canload-blocks-preload) does note this behavior and that it is by design. However, it does not give any indication as to why.

> The PreloadAllModules strategy does not load feature areas protected by a CanLoad guard. This is by design.

The language in the guide also isn't very clear. When I originally read that part of the guide, I misunderstood "areas protected by a CanLoadGuard" as only referring to areas where the `canLoad` guard check returned false.

## Expected behavior
<!-- Describe what the desired behavior would be. -->
Preloaders should decide whether to preload based on the boolean result of the `canLoad` guard (or the boolean result of the observable/promise).

If this is not possible, it should be more clear that `canLoad` negates any preloading strategy for that module. This could be through console warnings and/or better documentation.

## Minimal reproduction of the problem with instructions
<!--
For bug reports please provide the *STEPS TO REPRODUCE* and if possible a *MINIMAL DEMO* of the problem via
https://plnkr.co or similar (you can use this template as a starting point: http://plnkr.co/edit/tpl:AvJOMERrnz94ekVua0u5).
-->

## What is the motivation / use case for changing the behavior?
<!-- Describe the motivation or the concrete use case. -->

- The `canLoad` guard allows preventing navigation before a lazy loaded module is downloaded/bootstraped
- Preloading requires "loading" a module, therefore a `canLoad` option still makes logical sense
- The suggested use of `canActivate` over `canLoad` when preloading wastes network/memory/cpu resources
- The disabling of preloading by the `canLoad` option happens silently
- `canLoad` returns an observable or promise so it can delay loading for an async task (i.e. user login)
- custom preloading strategies are slightly harder to implement than a `canLoad` hook
- custom preloading can only be configured on a root or lazy loaded module level
- `PreloadAllModules` could be used in concert with `canLoad` for a simple selective loading strategy

## Environment

<pre><code>
Angular version: 5.0.3
<!-- Check whether this is still an issue in the most recent Angular version -->

Browser:
- [x] Chrome (desktop) version 63.0.3239.84 (Official Build) (64-bit)
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [x] IE version 11
- [ ] Edge version XX
 
For Tooling issues:
- Node version: v8.9.1  <!-- run `node --version` -->
- Platform: Windows 7 64-bit <!-- Mac, Linux, Windows -->

Others:
<!-- Anything else relevant?  Operating system version, IDE, package manager, HTTP server, ... -->
- Angular CLI: 1.5.4
</code></pre>