我正在努力将ng2-dragula绑定到AspNetCore SPA 模板。尝试了一切,但仍然得到:
Exception: Call to Node module failed with error: Error: Template parse errors:
Can't bind to 'dragula' since it isn't a known property of 'div'. ("
<div>
<div class='wrapper'>
<div class='container' [ERROR ->][dragula]='"first-bag"'>
<div>Drag/drop item 1</div>
</div>
"): ng:///AppModule/DragulaComponent.html@7:31
at syntaxError (C:\Users\...\ClientApp\dist\vendor.js:36125:34)
at ...
有人在 AspDotnetCoreSpa 中使用过 ng2-dragula 吗?
dragula.component.html
<div>
<div class='wrapper'>
<div class='container' [dragula]='"first-bag"'>
<div>Drag/drop item 1</div>
</div>
</div>
</div>
dragula.component.ts
import { Component } from '@angular/core';
import { DragulaModule, DragulaService } from 'ng2-dragula'
@Component({
selector: 'dragula',
templateUrl: './dragula.component.html',
styleUrls: ['../../../../node_modules/dragula/dist/dragula.min.css']
})
export class DragulaComponent {
}
app.module.client.ts
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { DragulaModule } from 'ng2-dragula';
import { HttpModule } from '@angular/http';
import { sharedConfig } from './app.module.shared';
@NgModule({
bootstrap: sharedConfig.bootstrap,
declarations: sharedConfig.declarations,
imports: [
BrowserModule,
FormsModule,
DragulaModule,
HttpModule,
...sharedConfig.imports
],
providers: [
{ provide: 'ORIGIN_URL', useValue: location.origin }
]
})
export class AppModule {
}
app.module.shared.ts
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { AppComponent } from './components/app/app.component'
import { NavMenuComponent } from './components/navmenu/navmenu.component';
import { HomeComponent } from './components/home/home.component';
import { FetchDataComponent } from './components/fetchdata/fetchdata.component';
import { CounterComponent } from './components/counter/counter.component';
import { DragulaComponent } from './components/dragula/dragula.component';
export const sharedConfig: NgModule = {
bootstrap: [ AppComponent ],
declarations: [
AppComponent,
NavMenuComponent,
CounterComponent,
FetchDataComponent,
DragulaComponent,
HomeComponent
],
imports: [
RouterModule.forRoot([
{ path: '', redirectTo: 'home', pathMatch: 'full' },
{ path: 'home', component: HomeComponent },
{ path: 'counter', component: CounterComponent },
{ path: 'fetch-data', component: FetchDataComponent },
{ path: 'dragula', component: DragulaComponent },
{ path: '**', redirectTo: 'home' }
])
]
};