fix(compiler_cli): normalize used directives
- e.g. needed for content projection. Closes #8677
This commit is contained in:
@ -0,0 +1,15 @@
|
||||
import {Component} from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'comp-with-proj',
|
||||
template: '<ng-content></ng-content>'
|
||||
})
|
||||
export class CompWithProjection {
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'main',
|
||||
template: '<comp-with-proj><span greeting="Hello world!"></span></comp-with-proj>',
|
||||
directives: [CompWithProjection]
|
||||
})
|
||||
export class MainComp {}
|
@ -0,0 +1,17 @@
|
||||
import {MainCompNgFactory} from '../src/projection.ngfactory';
|
||||
import {CompWithProjection} from '../src/projection';
|
||||
import {ReflectiveInjector, DebugElement, getDebugNode} from '@angular/core';
|
||||
import {browserPlatform, BROWSER_APP_STATIC_PROVIDERS, By} from '@angular/platform-browser';
|
||||
|
||||
describe("content projection", () => {
|
||||
it("should support basic content projection", () => {
|
||||
const appInjector = ReflectiveInjector.resolveAndCreate(BROWSER_APP_STATIC_PROVIDERS,
|
||||
browserPlatform().injector);
|
||||
var mainComp = MainCompNgFactory.create(appInjector);
|
||||
|
||||
var debugElement = <DebugElement>getDebugNode(mainComp.location.nativeElement);
|
||||
var compWithProjection = debugElement.query(By.directive(CompWithProjection));
|
||||
expect(compWithProjection.children.length).toBe(1);
|
||||
expect(compWithProjection.children[0].attributes['greeting']).toEqual('Hello world!');
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user