【问题标题】:Can't bind to 'stackConfig' since it isn't a known property of 'div'. ("无法绑定到“stackConfig”,因为它不是“div”的已知属性。 ("
【发布时间】:2017-08-26 18:07:46
【问题描述】:

我正在尝试按照本教程https://devdactic.com/ionic-2-tinder-cards 在 ionic2 中构建一个火种卡应用程序,但出现错误:

Unhandled Promise rejection: Template parse errors:
Can't bind to 'stackConfig' since it isn't a known property of 'div'. ("

有什么办法吗?

【问题讨论】:

  • 我已经完成了论坛上建议的几乎所有事情。仍然面临同样的问题。你找到解决办法了吗?如果您有任何工作回购,请与我分享。

标签: ionic-framework ionic2


【解决方案1】:

将这两个模块 HttpModule,SwingModule 添加到您的 pagename.module.ts 中,因为我认为本教程使用的是 ionic 2。我们必须单独将 swing 模块添加到创建的新页面中。

【讨论】:

  • 我在 pagename.module.ts 中添加了模块,但没有成功。面临同样的问题
【解决方案2】:

您需要在 app.module.ts 中添加 SwingModule 导入。请参阅https://github.com/ksachdeva/angular2-swing-example/blob/master/src/app/app.module.tsenter code here 上的示例应用配置

   @NgModule({
   declarations: [
       AppComponent
   ],
   imports: [
       BrowserModule,
       FormsModule,
       HttpModule,
       SwingModule
   ],
   providers: [],
   bootstrap: [AppComponent]
   })

【讨论】:

    【解决方案3】:
     cards: Array<any>;
      stackConfig: any;
      recentCard: string = '';
         constructor(public navCtrl: NavController,private http: Http, public navParams: NavParams,public modalCtrl: ModalController) {
            this.stackConfig = {
               throwOutConfidence: (offsetX, offsetY, element) => {
               return Math.min(Math.abs(offsetX) / (element.offsetWidth/2), 1);
               },
              transform: (element, x, y, r) => {
              this.onItemMove(element, x, y, r);
              },
              throwOutDistance: (d) => {
                return 800;
              }
            };
    
          }
          ngAfterViewInit() {
            // Either subscribe in controller or set in HTML
            this.swingStack.throwin.subscribe((event: DragEvent) => {
              event.target.style.background = '#ffffff';
            });
    
            this.cards = [{email: ''}];
            this.addNewCards(1);
          }
    

    【讨论】:

    • 使用stackConfig:任意;而不是 stackConfig:StackConfig;
    猜你喜欢
    • 2020-10-24
    • 1970-01-01
    • 1970-01-01
    • 2019-11-04
    • 2017-09-09
    • 2021-05-08
    • 2020-09-10
    • 2017-03-29
    相关资源
    最近更新 更多