MCPcopy Index your code
hub / github.com/angular/angular / compileDirective

Function compileDirective

packages/core/src/render3/jit/directive.ts:295–323  ·  view source on GitHub ↗
(type: Type<any>, directive: Directive | null)

Source from the content-addressed store, hash-verified

293 * will resolve when compilation completes and the directive becomes usable.
294 */
295export function compileDirective(type: Type<any>, directive: Directive | null): void {
296 let ngDirectiveDef: any = null;
297
298 addDirectiveFactoryDef(type, directive || {});
299
300 Object.defineProperty(type, NG_DIR_DEF, {
301 get: () => {
302 if (ngDirectiveDef === null) {
303 // `directive` can be null in the case of abstract directives as a base class
304 // that use `@Directive()` with no selector. In that case, pass empty object to the
305 // `directiveMetadata` function instead of null.
306 const meta = getDirectiveMetadata(type, directive || {});
307 const compiler = getCompilerFacade({
308 usage: JitCompilerUsage.Decorator,
309 kind: 'directive',
310 type,
311 });
312 ngDirectiveDef = compiler.compileDirective(
313 angularCoreEnv,
314 meta.sourceMapUrl,
315 meta.metadata,
316 );
317 }
318 return ngDirectiveDef;
319 },
320 // Make the property configurable in dev mode to allow overriding in tests
321 configurable: !!ngDevMode,
322 });
323}
324
325function getDirectiveMetadata(type: Type<any>, metadata: Directive) {
326 const name = type && type.name;

Callers 3

directives.tsFile · 0.90
compileTypesSyncMethod · 0.85

Calls 4

getCompilerFacadeFunction · 0.90
addDirectiveFactoryDefFunction · 0.85
getDirectiveMetadataFunction · 0.70
compileDirectiveMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…