Issue 1:
Hello,

I want to propose to you to extend router url_parser in angular, to make it smarter.

On a big projects, I have to deal with complex routes which have optional params and I want to work only with one route and also keep it simple and clean, also I don't want duplicated urls or empty segments in them or something like that.

For example, if I have a pagination on the page /cars, I can access the same page via /cars or /cars/page-2. Also I don't want to have url like /cars/page-1 because it is the same as /cars.

To avoid this kind of problems, I made for my backend framework a smarter routes which resolve all issues which I described above, and I will be happy if you will implement it too in the standard angular router to make all the community happier.

I have made them in that way:

{<paramName>?:<defaultValue>|<regex>}? - You can define a parameter which may be optional, with a default value and restrict it by regex, or just add "?" symbol at the end of paramName, to make it greedy(for example {systemName?} is equal to (.+?), {systemName?}? is equal to (.+?)?).

[<optionalRouteSegment>] - You can define an optional part of the route if it would not be valid in the segment from the inside. This syntax goes recursively. For example [/engine/{engineName}[/year/{engineYear}]/v/{engineVersion}]

For example I have a route with syntax /cars[/category/{categoryName?}][/page/{page:1|[1-9][0-9]*}].

categoryName is greedy and required in his segment and could be any symbol. If it does't exists, all the segment will disappear. Why greedy? Because it has an optional segment after, which will match if you will not set the greedy.

page is also required in his segment, has a default value and could be any number which starts from 1.

It will be valid via next urls:

If i call it with no params or with {page: 1}, i will get /cars, because it doesn't have categoryName and the page value is the same as default value.

If i call it with {page: 2}, i will get /cars/page/2.

If i call it with {categoryName: 'supercar'} or with {categoryName: 'supercar', page: 1}, I will get /cars/category/supercar.

If i call it with {categoryName: 'supercar', page: 2}, I will get /cars/category/supercar/page/2.

You get the idea how smart can they be? And this is a big plus for the seo.

Cheers.

Issue 2:
I'm submitting a ... (check one with "x")

[ ] bug report => search github for a similar issue or PR before submitting
[x] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

Human readable error text is informative only and can't be minified for production build. This text does not compress well with gzip.

Expected behavior

Suggest moving this informative error text to console.error() to work well with UglifyJS drop_console.

Minimal reproduction of the problem with instructions

From

new Error("long informative error message...")

To

console.error("long informative error message...")

new Error()

What is the motivation / use case for changing the behavior?

Informative-only error strings are verbose and cannot be dropped in minification.

Suggest moving most informative-only human-readable text to console.error() to work well with UglifyJS options drop_console. It might not be significant, but minification saving may be 4 or 5 KB for total build.

Top affected files are:

./forms/src/directives/error_examples.ts (1217 bytes of informative text)

./forms/src/directives/reactive_error.ts (1286 bytes of informative text)

./forms/src/directives/template_driven_errors.ts (1415 bytes of informative text)

./common/src/facade/errors.ts

./core/src/di/reflective_errors.ts

./core/src/facade/errors.ts

./core/testing/facade/errors.ts

Please tell us about your environment:

Windows 7

Angular version: 2.0.X

2.4.9

Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]

all

Language: [all | TypeScript X.X | ES6/7 | ES5]

Typescript

Webpack AOT

UglifyJS minify compiler

Node (for AoT issues): node --version =

7.2.1