簡體   English   中英

角2父級和子級分量

[英]angular 2 parent and child component

  • 我正在嘗試學習打字稿和angular2。
  • 所以我試圖在我的小提琴中加入父母和孩子的成分。
  • 但我沒有成功。 甚至做了一些研究
  • 我收到此錯誤Uncaught ReferenceError:require未定義
  • 你能告訴我如何解決它。
  • 在下面提供我的代碼。

https://jsfiddle.net/t9ef4cdt/

@Component({
  selector: 'child',
  template: `
    <div>
      <h2>{{name}}</h2>
      <button (click) = "rename()" > Rename Parent </button>
    </div>
  `,
})
export class Child {

@Input() name:string;
@Output() nameChanged: EventEmitter<string> = new EventEmitter<string>()

問題是您正在使用不推薦使用的Angular版本(因為它出現在您的導入中),您可以在這里找到您的代碼。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM