我知道这个问题已经被问过好几次了,我看了很多,比如
不幸的是,他们都没有为我工作。
我已经在我的笔记本上安装了 Ubuntu 和 Windows。
"Hello,World!"使用 c 中的文本编辑器开发了一个简单的程序。$ gcc -o hello.out -g -Wall -pedantic hello.c'./output.out'Hello, World!所以我在这里交叉开发。我切换到 Windows 并继续前进。
现在,我尝试使它成为一个可执行文件,以便在 Windows 上运行它。我知道 Windows 无法处理'$ ./output.out',好吧,让我们将其设为可执行文件。
在 Windows 下,我已经
$ gcc -o hello.exe -g -Wall -pedantic hello.c注意:我写的是hello.exe而不是hello.out或hello.c
'$ ./output.exe'如果是这种情况,我可以使用以下语法将一些数据传递给子级:
父组件.ts
// imports..
selector: "app-parent",
templateURL: "./parent.component.html",
// ...
export class ParentComponent{
public statement= "I am your father"!;
}
Run Code Online (Sandbox Code Playgroud)
父组件.html
<div>
<h1>
My name is Darth Vader
</h1>
</div>
<app-child [luke] = "statement"></app-child> // child selector!
Run Code Online (Sandbox Code Playgroud)
子组件.ts
// imports..
selector: "app-child",
templateURL: `<h2>{{"Luke, " + luke}}</h2>`
// ...
export class TestComponent{
@Input() public luke;
}
Run Code Online (Sandbox Code Playgroud)
结果应该是:
卢克,我是你爸!
到目前为止没有什么特别的。
现在,如果我的子组件包含另一个子组件并因此充当其父组件怎么办?
子组件.html
<app-secondChild></app-secondChild> // selector of second.child.component.ts!
Run Code Online (Sandbox Code Playgroud)
secondary.child.component.html
<app-thirdChild></app-thirdChild> // selector of third.child.component.ts!
Run Code Online (Sandbox Code Playgroud)
Third.child.component.html
<app-fourthChild></app-fourthChild> // selector of fourth.child.component.ts!
Run Code Online (Sandbox Code Playgroud)
基本上,我想将数据从父级传递到最后一个子级,以激活一些 …