0

Compiling from TypeScript with Browserify...I'm writing a UDM that injects new DOM elements into the page dynamically...I'd like to apply an NG2 @Directive() to them, but not being "called" from anywhere else in the code, the compile process bypasses the directive's import

Any suggestions would be appreciated.

1
  • 1
    Please add some code that demonstrates what you try to accomplish and what you have tried and where you failed. What is "UDM that injects new DOM elements into the page dynamically" Jul 19, 2016 at 16:57

1 Answer 1

0

If you want to apply directives to elements in a component, you need to specify them in its directives attribute:

import { SomeDirective } from './some.directive';

@Component({
  (...)
  directives: [ SomeDirective ]
})
export class SomeComponent {
  (...)
}

In this case, the import won't be bypassed during compilation. If you don't specify the directive in the attribute, it would be the case...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.