Answer the question
In order to leave comments, you need to log in
Why doesn't the attribute directive work?
There is a core.module.ts module:
import { NgModule } from '@angular/core';
import { TestDirective } from './test/test-directive';
import { Test } from './test/component';
@NgModule({
declarations: [
Test,
TestDirective
],
exports: [
Test,
TestDirective
]
})
export class CoreModule {
}
import { Component } from '@angular/core';
@Component({
selector: 'test',
template: 'test'
})
export class Test {
}
import { Directive } from "@angular/core";
@Directive({
selector: '[myTest]'
})
export class TestDirective{
}
@NgModule({
imports: [
CoreModule
],
declarations: [
AppComponent
]
...
<test></test> <a href="/hello" [myTest]>hello</a>
Unhandled Promise rejection: Template parse errors:
Can't bind to 'myTest' since it isn't a known property of 'a'.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question