Angular Can';t读取组件中的变量';s的html文件
我试图显示一个数组的数据(在Angular Can';t读取组件中的变量';s的html文件,angular,Angular,我试图显示一个数组的数据(在chat.component中填充) ..inchat.component.html <div class="matchesList" *ngFor="let match of matchesList"> <p>{{match}}</p> </div> 为什么在chat.component.html中无法访问matchesList的数据 谢谢大家! 之所以发生这种情况,是因为用于调用This.chatComp.
chat.component
中填充)
..inchat.component.html
<div class="matchesList" *ngFor="let match of matchesList">
<p>{{match}}</p>
</div>
为什么在chat.component.html
中无法访问matchesList
的数据
谢谢大家! 之所以发生这种情况,是因为用于调用
This.chatComp.loadMatches()
的实例与用于呈现以下模板的实例不同-
chat.component.html
<div class="matchesList" *ngFor="let match of matchesList">
<p>{{match}}</p>
</div>
发生这种情况的原因是,用于调用
This.chatComp.loadMatches()
的实例与用于呈现以下模板的实例不同-
chat.component.html
<div class="matchesList" *ngFor="let match of matchesList">
<p>{{match}}</p>
</div>
这不是您使用组件的方式,您不需要将其添加到组件
提供程序:[……]
。这是用于服务的。@marshalllegend感谢您的回答,我能做什么?中的回答应该有助于澄清如何在子组件中调用方法。@marshalllegend非常感谢!它现在运行良好,我需要进入更多的文档我的头!再次谢谢,很高兴听到这个消息!这不是您使用组件的方式,您不需要将其添加到组件提供程序:[……]
。这是用于服务的。@marshalllegend感谢您的回答,我能做什么?中的回答应该有助于澄清如何在子组件中调用方法。@marshalllegend非常感谢!它现在运行良好,我需要进入更多的文档我的头!再次谢谢,很高兴听到这个消息!
chat.component.html
<div class="matchesList" *ngFor="let match of matchesList">
<p>{{match}}</p>
</div>
1. Chat Component.ts/.html
2. Home component.ts/.html
3. The parent [if any] which holds those two components [If not then let us know how those are rendered [i.e. Parent/Child?]