【问题标题】:I get 'Error: Input is not defined' when trying to pass parameter to child component尝试将参数传递给子组件时出现“错误:未定义输入”
【发布时间】:2016-10-27 11:24:37
【问题描述】:

我正在练习 angular2,我对它真的很陌生。 我构建了 2 个组件 - 一个父级和它的子级。 当我尝试将某些参数从父组件传递给其子组件时,我得到“错误:未定义输入”。有人可以帮我解决这个问题,因为我看不到我做错了什么。

export class SquadComponent{
  @Input() selectedteam;
}

my plunker

【问题讨论】:

    标签: angular


    【解决方案1】:

    在这样使用之前导入Input

    import { Component, Input } from 'angular2/core'
    

    工作示例http://plnkr.co/edit/ZXI8FwfYvrcAkTxtUPNy?p=preview

    更新

    import { Component, Input } from '@angular/core'
    

    【讨论】:

    • 好吧,我想我得习惯导入所有东西的想法了……谢谢
    • “输出”也是如此?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-11-02
    • 2021-01-15
    • 2020-01-26
    • 1970-01-01
    • 2021-05-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多