refactor(core): add a deprecation message for using PLATFORM_DIRECTIVES
/ PLATFORM_PIPES
/ CompilerConfig
/ XHR
as regular providers in bootstrap
.
We still support this via a hack, but should remove this soon. This also fixes tests for module directives / pipes as they used directives / pipes that were already present in the underlying platform.
This commit is contained in:
@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
import {LowerCasePipe, NgIf} from '@angular/common';
|
||||
import {ANALYZE_FOR_PRECOMPILE, AppModule, Component, ComponentFactoryResolver, Inject, Injectable, OpaqueToken} from '@angular/core';
|
||||
import {ANALYZE_FOR_PRECOMPILE, AppModule, Component, ComponentFactoryResolver, Directive, Inject, Injectable, Input, OpaqueToken, Pipe} from '@angular/core';
|
||||
import {BrowserModule} from '@angular/platform-browser';
|
||||
|
||||
@Injectable()
|
||||
@ -19,10 +19,18 @@ export class SomeService {
|
||||
export class NestedService {
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'cmp',
|
||||
template: `<div [title]="'HELLO' | lowercase"></div><div *ngIf="true"></div>`
|
||||
})
|
||||
@Directive({selector: '[someDir]', host: {'[title]': 'someDir'}})
|
||||
export class SomeDirective {
|
||||
@Input()
|
||||
someDir: string;
|
||||
}
|
||||
|
||||
@Pipe({name: 'somePipe'})
|
||||
export class SomePipe {
|
||||
transform(value: string): any { return `transformed ${value}`; }
|
||||
}
|
||||
|
||||
@Component({selector: 'cmp', template: `<div [someDir]="'someValue' | somePipe"></div>`})
|
||||
export class SomeComp {
|
||||
constructor() {}
|
||||
}
|
||||
@ -36,8 +44,8 @@ export class NestedModule {
|
||||
}
|
||||
|
||||
@AppModule({
|
||||
directives: [NgIf],
|
||||
pipes: [LowerCasePipe],
|
||||
directives: [SomeDirective],
|
||||
pipes: [SomePipe],
|
||||
providers: [SomeService],
|
||||
precompile: [SomeComp],
|
||||
modules: [NestedModule, BrowserModule]
|
||||
@ -46,8 +54,8 @@ export class SomeModule {
|
||||
}
|
||||
|
||||
@AppModule({
|
||||
directives: [NgIf],
|
||||
pipes: [LowerCasePipe],
|
||||
directives: [SomeDirective],
|
||||
pipes: [SomePipe],
|
||||
precompile: [ParentComp],
|
||||
modules: [BrowserModule]
|
||||
})
|
||||
|
@ -37,25 +37,19 @@ describe('AppModule', () => {
|
||||
|
||||
it('should support module directives and pipes', () => {
|
||||
var compFixture = createComponent(SomeComp, SomeModuleNgFactory);
|
||||
var debugElement = compFixture.debugElement;
|
||||
|
||||
// NgIf should work, is being used as module directive
|
||||
expect(debugElement.children.length).toBe(1);
|
||||
compFixture.detectChanges();
|
||||
expect(debugElement.children.length).toBe(2);
|
||||
expect(debugElement.children[0].properties['title']).toBe('hello');
|
||||
|
||||
var debugElement = compFixture.debugElement;
|
||||
expect(debugElement.children[0].properties['title']).toBe('transformed someValue');
|
||||
});
|
||||
|
||||
it('should support module directives and pipes on nested components', () => {
|
||||
var compFixture = createComponent(ParentComp, SomeModuleUsingParentCompNgFactory);
|
||||
var debugElement = compFixture.debugElement;
|
||||
|
||||
debugElement = debugElement.children[0];
|
||||
// NgIf should work, is being used as module directive
|
||||
expect(debugElement.children.length).toBe(1);
|
||||
compFixture.detectChanges();
|
||||
expect(debugElement.children.length).toBe(2);
|
||||
expect(debugElement.children[0].properties['title']).toBe('hello');
|
||||
|
||||
var debugElement = compFixture.debugElement;
|
||||
debugElement = debugElement.children[0];
|
||||
expect(debugElement.children[0].properties['title']).toBe('transformed someValue');
|
||||
});
|
||||
|
||||
it('should support child moduless', () => {
|
||||
|
Reference in New Issue
Block a user