Commit Graph

576 Commits

Author SHA1 Message Date
Kara 9d265b6f61 feat(forms): add modules for forms and deprecatedForms (#9859)
Closes #9732

BREAKING CHANGE:

We have removed the deprecated form directives from the built-in platform directive list, so apps are not required to package forms with their app. This also makes forms friendly to offline compilation.

Instead, we have exposed three modules:

OLD API:
- `DeprecatedFormsModule`

NEW API:
- `FormsModule`
- `ReactiveFormsModule`

If you provide one of these modules, the default forms directives and providers from that module will be available to you app-wide.  Note: You can provide both the `FormsModule` and the `ReactiveFormsModule` together if you like, but they are fully-functional separately.

**Before:**
```ts
import {disableDeprecatedForms, provideForms} from @angular/forms;

bootstrap(App, [
   disableDeprecatedForms(),
   provideForms()
]);
```

**After:**

```ts
import {DeprecatedFormsModule} from @angular/common;

bootstrap(App, {modules: [DeprecatedFormsModule] });
```

-OR-

```ts
import {FormsModule} from @angular/forms;

bootstrap(App, {modules: [FormsModule] });
```

-OR-

```ts
import {ReactiveFormsModule} from @angular/forms;

bootstrap(App, {modules: [ReactiveFormsModule] });
```

You can also choose not to provide any forms module and run your app without forms.

Or you can choose not to provide any forms module *and* provide form directives at will.  This will allow you to use the deprecatedForms API for some components and not others.

```
import {FORM_DIRECTIVES, FORM_PROVIDERS} from @angular/forms;

@Component({
   selector: some-comp,
   directives: [FORM_DIRECTIVES],
   providers: [FORM_PROVIDERS]
})
class SomeComp
```
2016-07-07 11:32:51 -07:00
Roberto Simonetti 776a83f9da doc(i18nPluralPipe): update API doc example (#9862) 2016-07-07 08:48:37 -07:00
Andrei Tserakhau f29457f3f0 fix(datePipe): short timezone not displayed, closes #9812 (#9816) 2016-07-07 08:47:30 -07:00
Georgii Dolzhykov a005d1595e chore(compiler-cli): correct homepage URL in package.json (#9869) 2016-07-07 08:43:53 -07:00
Tobias Bosch 8d746e3f67 feat(testing): add implicit test module
Every test now has an implicit module. It can be configured via `configureModule` (from @angular/core/testing)
to add providers, directives, pipes, ...

The compiler now has to be configured separately via `configureCompiler` (from @angular/core/testing)
to add providers or define whether to use jit.

BREAKING CHANGE:
- Application providers can no longer inject compiler internals (i.e. everything
  from `@angular/compiler). Inject `Compiler` instead. This reflects the
  changes to `bootstrap` for module support (3f55aa609f).
- Compiler providers can no longer be added via `addProviders` / `withProviders`.
  Use the new method `configureCompiler` instead.
- Platform directives / pipes need to be provided via
  `configureModule` and can no longer be provided via the
  `PLATFORM_PIPES` / `PLATFORM_DIRECTIVES` tokens.
- `setBaseTestProviders()` was renamed into `initTestEnvironment` and 
  now takes a `PlatformRef` and a factory for a
  `Compiler`.
- E.g. for the browser platform:
  
  BEFORE:
  ```
  import {setBaseTestProviders} from ‘@angular/core/testing’;
  import {TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS,
      TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS} from ‘@angular/platform-browser-dynamic/testing’;
  
  setBaseTestProviders(TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS,
      TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS);   
  ```

  AFTER:
  ```
  import {setBaseTestProviders} from ‘@angular/core/testing’;
  import {browserTestCompiler, browserDynamicTestPlatform,
      BrowserDynamicTestModule} from ‘@angular/platform-browser-dynamic/testing’;
  
  initTestEnvironment(
      browserTestCompiler,
      browserDynamicTestPlatform(),
      BrowserDynamicTestModule);

  ```
- E.g. for the server platform:
  
  BEFORE:
  ```
  import {setBaseTestProviders} from ‘@angular/core/testing’;
  import {TEST_SERVER_PLATFORM_PROVIDERS,
      TEST_SERVER_APPLICATION_PROVIDERS} from ‘@angular/platform-server/testing/server’;
  
  setBaseTestProviders(TEST_SERVER_PLATFORM_PROVIDERS,
      TEST_SERVER_APPLICATION_PROVIDERS);   
  ```

  AFTER:
  ```
  import {setBaseTestProviders} from ‘@angular/core/testing’;
  import {serverTestCompiler, serverTestPlatform,
      ServerTestModule} from ‘@angular/platform-browser-dynamic/testing’;
  
  initTestEnvironment(
      serverTestCompiler,
      serverTestPlatform(),
      ServerTestModule);

  ```

Related to #9726
Closes #9846
2016-07-06 18:04:19 -07:00
vsavkin 37e6da6dfb refactor(router): clean up naming 2016-07-06 16:19:52 -07:00
vsavkin 8aa2a0c1b2 feat(router): add RouterAppModule 2016-07-06 16:00:40 -07:00
vsavkin 6bfd514caf fix(router): remove a circular dep 2016-07-06 14:38:05 -07:00
vsavkin 8ebb8e44c8 feat(router): add support for lazily loaded modules 2016-07-06 14:38:05 -07:00
vsavkin 6fcf962fb5 feat(core): add AddModuleFactoryLoader 2016-07-06 14:38:05 -07:00
Patrice Chalin 2708ce6a17 docs(api): fix links (#9852) 2016-07-06 14:34:27 -07:00
Chuck Jazdzewski 30bec78da3 fix(compiler): Missing metadata files should result in undefined (#9704)
RelectorHost threw an exception when metadata was requested for a
.d.ts file that didn't have a .metadata.json file.  Changed it to
return undefined.

Fixes #9678
2016-07-06 14:26:31 -07:00
Chuck Jazdzewski 9a04fcd061 feat(compiler): Expression span information and error correction (#9772)
Added error correction so the parser always returns an AST
Added span information to the expression parser
Refactored the test to account for the difference in error reporting
Added tests for error corretion
Modified tests to validate the span information
2016-07-06 14:06:47 -07:00
Patrice Chalin ae62f082fd docs(api): fix broken example urls (#9828) 2016-07-06 13:57:38 -07:00
Matias Niemelä 9cc3b2ca9e fix(animations): ensure a null easing value is never used with web-animations
Closes #9780
Closes #9752
2016-07-06 11:25:54 -07:00
Matias Niemelä 3fe1cb0253 refactor(core): ensure CSS parser uses ParseSourceSpan to track ast locations
This commit also fixes up any remaining TODO comments.

Closes #9778
2016-07-06 11:22:45 -07:00
Tobias Bosch 3f55aa609f feat(browser): use AppModules for bootstrap in the browser
This introduces the `BrowserModule` to be used for long form
bootstrap and offline compile bootstrap:

```
@AppModule({
  modules: [BrowserModule],
  precompile: [MainComponent],
  providers: […], // additional providers
  directives: […], // additional platform directives
  pipes: […] // additional platform pipes
})
class MyModule {
  constructor(appRef: ApplicationRef) {
    appRef.bootstrap(MainComponent);
  }
}

// offline compile
import {bootstrapModuleFactory} from ‘@angular/platform-browser’;
bootstrapModuleFactory(MyModuleNgFactory);

// runtime compile long form
import {bootstrapModule} from ‘@angular/platform-browser-dynamic’;
bootstrapModule(MyModule);
```

The short form, `bootstrap(...)`, can now creates a module on the fly,
given `directives`, `pipes, `providers`, `precompile` and `modules`
properties.

Related changes:
- make `SanitizationService`, `SecurityContext` public in `@angular/core` so that the offline compiler can resolve the token
- move `AnimationDriver` to `platform-browser` and make it
  public so that the offline compiler can resolve the token

BREAKING CHANGES:
- short form bootstrap does no longer allow
  to inject compiler internals (i.e. everything 
  from `@angular/compiler). Inject `Compiler` instead.
  To provide custom providers for the compiler,
  create a custom compiler via `browserCompiler({providers: [...]})`
  and pass that into the `bootstrap` method.
2016-07-02 20:35:09 -07:00
Tobias Bosch 74b45dfbf8 Revert "refactor(core): ensure CSS parser uses ParseSourceSpan to track ast locations"
This reverts commit 5c9f871b21.
2016-07-01 21:21:56 -07:00
Matias Niemelä 5c9f871b21 refactor(core): ensure CSS parser uses ParseSourceSpan to track ast locations
This commit also fixes up any remaining TODO comments.

Closes #9285
2016-07-01 17:18:14 -07:00
Kara 77dc6ef411 fix(forms): mark control containers as touched when child controls are touched (#9735) 2016-07-01 15:36:04 -07:00
Andrei Tserakhau 5eca6e4e40 bug(datePipe): passing "hh" to the datepipe (#9774)
closes #9759
2016-07-01 15:34:57 -07:00
vsavkin 0c65d5cf2b fix(router): handle router outlets in ngIf 2016-06-30 22:14:42 -07:00
vsavkin f65ebec3ed fix(router): update links when query params change 2016-06-30 22:14:42 -07:00
vsavkin 81bf3f66ca docs(router): rename global redirects into absolute redirects 2016-06-30 22:14:42 -07:00
Rob Wormald 3cbded6694 fix(forms): use change event for select multiple (#9713) 2016-06-30 20:24:39 -07:00
PatrickJS 137fff9632 fix(router): remove private and internal annotations (#9753) 2016-06-30 19:39:13 -07:00
Kara 695c08b9dd test(forms): add test for multi-select and custom accessors (#9624) 2016-06-30 18:04:00 -07:00
Michael afb72164e4 fix(docs): typo in comments (#9743)
correct a typo in comments
2016-06-30 15:18:41 -07:00
vsavkin 01de58d650 chore(router): bump up version number 2016-06-30 14:58:59 -07:00
Rob Wormald dabf214f17 fix(router): remove private and internal annotations (#9745) 2016-06-30 14:47:55 -07:00
vsavkin fb2539e1d5 fix(router): remove the precompile warning 2016-06-30 14:33:04 -07:00
Tobias Bosch ad9f02a73e chore: enable cyclic dependency check
Closes #9742
2016-06-30 14:28:22 -07:00
Tobias Bosch 2d73583253 chore(compiler): fix cyclic dependency 2016-06-30 14:28:22 -07:00
Alex Eagle 73f017bad9 fix(typescript): make router compile with typescript@next
fixes #9731
2016-06-30 11:51:52 -07:00
vsavkin 055282f156 chore(router): bump up version number 2016-06-30 11:45:31 -07:00
vsavkin fe7de53b89 chore(router): update router change log 2016-06-30 11:45:31 -07:00
Tobias Bosch 17e4cfc748 feat(core): introduce `@AppModule`
Main part for #9726
Closes #9730
2016-06-30 11:34:40 -07:00
vsavkin a3b90411aa fix(router): fix RouterLinkActive to handle the case when the link has extra paths 2016-06-30 09:26:57 -07:00
vsavkin 5781b96490 fix(router): redirect should not add unnecessary brackets 2016-06-30 09:26:57 -07:00
vsavkin f208ee0d57 fix(router): reexport router directives 2016-06-30 09:26:57 -07:00
ipinak 8aa388de6c doc(directive): fixes incorrect example code (#9635) 2016-06-29 22:16:43 -07:00
Tobias Bosch 51d4c9dcbd fix(compiler): make code easier to type check
These changes are needed for the G3 sync as we use a different version/settings of Typescript than on Github.

closes #9701
2016-06-29 10:43:58 -07:00
Tobias Bosch e81dea695c fix(compiler): report not existing files as errors
Closes #9690
2016-06-29 07:35:34 -07:00
Miško Hevery 3fec27961e fix: support *directive on <template> (#9691)
fixes #7315
2016-06-28 21:53:41 -07:00
vsavkin 3784696b9e fix(router): make the contstructor of the router service public 2016-06-28 18:39:37 -07:00
vsavkin 8c45aebc18 fix(router): make router links work on non-a tags 2016-06-28 18:39:37 -07:00
Martin Probst 810c722413 docs(security): point users to docs when sanitization fails. (#9680) 2016-06-28 18:13:46 -07:00
Igor Minar e2116c53f3 fix(upgrade): add peerDependency on platform-browser-dynamic (#9674)
Closes #9623
2016-06-28 17:27:28 -07:00
vsavkin 296a447e3c docs(router): add api docs 2016-06-28 14:49:29 -07:00
Kara 0961bd1eff feat(forms): use formControlName on radio buttons when name is absent (#9681) 2016-06-28 15:21:53 -06:00