12
यह सुनिश्चित नहीं है कि मेरा * ngFor लूप कुछ भी क्यों प्रिंट नहीं कर रहा है।* एनजी-टेम्पलेट आउटपुट पर ngFor कुछ भी नहीं कोणीय 2
<table class="table table-hover">
<thead>
<tr>
<th>Name</th>
<th>Email</th>
<th>Company</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<!-- NGFOR ATTEMPTED HERE -- no content printed -->
<ng-template *ngFor="let xb of tempData">
<tr data-toggle="collapse" data-target="#demo1" class="accordion-toggle">
<td>{{ xb.name }}</td>
<td>{{ xb.email }}</td>
<td>{{ xb.company }}</td>
<td>{{ xb.status }}</td>
</tr>
<!-- other content -->
</ng-template>
</tbody>
</table>
फिर, मेरे सरल घटक में मैं निम्नलिखित है:
import { Component } from '@angular/core';
@Component({
selector: 'my-profile-exhibitors',
templateUrl: './profile-exhibitors.component.html',
styleUrls: ['./profile-exhibitors.component.scss']
})
export class ProfileExhibitorsComponent {
public tempData: any = [
{
'name': 'name1',
'email': '[email protected]',
'company': 'company',
'status': 'Complete'
},
{
'name': 'name2',
'email': '[email protected]',
'company': 'company',
'status': 'Incomplete'
}
];
constructor() {}
}
मुझे इस कोड चलाने के लिए, मैं शून्य आउटपुट प्राप्त मैं एक HTML फ़ाइल में निम्न कोड की है। भी weirder कि जब मैं डिबग उपकरण का उपयोग कर तत्व का चयन मैं यह देख रहा है:
ऐसा लगता है कि इसे सही ढंग से मेरी वस्तु को पहचानता है, लेकिन फिर कुछ भी नहीं आउटपुट।
धन्यवाद! और जो भी 'एनजी-टेम्पलेट' के लिए सिंटैक्स डिज़ाइन किया गया है उसे –
पर जला दिया जाना चाहिए, यह सुनिश्चित नहीं है कि आप किस बारे में शिकायत कर रहे हैं। यह सामान्य कोणीय टेम्पलेट वाक्यविन्यास है। उन्होंने '' तत्वों पर अधिक संक्षिप्त और अधिक सामान्य '* xxx' वाक्यविन्यास का उपयोग करने में सक्षम होने के लिए '' पेश किया। –
उन्होंने एनजी-कंटेनर के साथ एक स्मार्ट निर्णय लिया। वह वाक्यविन्यास बेहद अनूठा है। –