Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 11.0.3无法绑定到指令,因为它不是元素的已知属性_Angular_Angular Directive - Fatal编程技术网

Angular 11.0.3无法绑定到指令,因为它不是元素的已知属性

Angular 11.0.3无法绑定到指令,因为它不是元素的已知属性,angular,angular-directive,Angular,Angular Directive,我通过Angular CLI生成了新的@指令,并将其导入我的app.module.ts: import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; import { AppRoutingModule } from './app-routing.module'; import { AppComponent } from './app.component

我通过Angular CLI生成了新的@指令,并将其导入我的app.module.ts:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppRoutingModule } from './app-routing.module';

import { AppComponent } from './app.component';
import { HttpClientModule } from '@angular/common/http';
import { InMemoryWebApiModule } from 'angular-in-memory-web-api';
import { DatosEnMemoriaService } from './datos-en-memoria.service';
import { ClonarDirective } from './investigaciones/marta/clonar.directive';
@NgModule({
  declarations: [
    AppComponent,
    ClonarDirective,
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,
    HttpClientModule,
    InMemoryWebApiModule.forRoot(DatosEnMemoriaService, {
      passThruUnknownUrl: true, post204: false, put204: false
  })
  ],  
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }
我尝试在mycomponent.html中使用

<li *appClonar="3">
  <button (click)="this.router.navigateByUrl('/gesprodes');"  >
    Gesprodes
    <span>Inicia a aplicación de gesprodes</span>
  </button>
</li>
指令1.ts:

import { Directive,Input,TemplateRef,ViewContainerRef } from '@angular/core';
 
@Directive({
  selector: '[appClonar]'
})
export class ClonarDirective {
 
  constructor(private tp:TemplateRef<any>,
              private vcr:ViewContainerRef) { }
 
    @Input() appClonar:number;
  ngOnInit(): void {
     this.vcr.createEmbeddedView(this.tp);
 
    console.log(this.appClonar);
    for(let i = 0; i<this.appClonar ;i++){
          this.vcr.createEmbeddedView(this.tp);
        }
  }
}
我得到了一个错误:

core.js:9813 NG0303:无法绑定到'appClonar',因为它不是'li'的已知属性

我尝试了几乎所有可能的改变,遵循这一点,一切都应该是可行的,但事实并非如此

我的版本:11.0.3 我的版本节点:12.0.0

有什么帮助吗你试过这个吗

<li [appClonar] >
</li>

这可不是一回事。Clonar是一个结构指令,需要与*appClonar一起使用。