我正在使用Jhipster 4和Angular 2.0創建應用程序。我是所有這些員工的新手。Jhipster 4如何把實體組件(列表)放在主屏幕上
比方說,我有兩個實體:客戶和任務與一對多關係。
我想在主屏幕上有客戶名單(前10名)。 下一步,我想添加屬於他的所有任務的客戶詳細信息視圖列表。
我已經更新home.component.ts添加CustomerComponent
import { Component, OnInit } from '@angular/core';
import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap';
import { EventManager, JhiLanguageService } from 'ng-jhipster';
import { Account, LoginModalService, Principal } from '../shared';
import { CustomerComponent, CustomerService, Customer } from '../entities/customer/'; // <---
@Component({
selector: 'jhi-home',
templateUrl: './home.component.html',
styleUrls: [
'home.css'
],
entryComponents: [
CustomerComponent // <---
],
})
export class HomeComponent implements OnInit {
account: Account;
modalRef: NgbModalRef;
constructor(
private jhiLanguageService: JhiLanguageService,
private principal: Principal,
private loginModalService: LoginModalService,
private eventManager: EventManager
) {
this.jhiLanguageService.setLocations(['home']);
}
ngOnInit() {
this.principal.identity().then(
(account) => {
this.account = account;
});
this.registerAuthenticationSuccess();
}
registerAuthenticationSuccess() {
this.eventManager.subscribe('authenticationSuccess', (message) => {
this.principal.identity().then((account) => {
this.account = account;
});
});
}
isAuthenticated() {
return this.principal.isAuthenticated();
}
login() {
this.modalRef = this.loginModalService.open();
}
}
而這些更改後的home.component.html我加JHI-客戶
<div class="row">
<div class="col-md-3">
<span class="hipster img-fluid img-rounded"></span>
</div>
<div class="col-md-9">
<h1 class="display-4" jhiTranslate="home.title">Welcome, Java Hipster!</h1>
<p class="lead" jhiTranslate="home.subtitle">This is your homepage</p>
<div [ngSwitch]="isAuthenticated()">
<div class="alert alert-success" *ngSwitchCase="true">
<span *ngIf="account" jhiTranslate="home.logged.message"
translateValues="{username: '{{account.login}}'}"> You are logged in as user "{{account.login}}". </span>
</div>
<div *ngSwitchCase="true">
<jhi-customer>Loading top 10 customers...</jhi-customer>
</div>
</div>
</div>
</div>
我只看到
載入中頂部10個客戶...
你能幫我找到我做錯了什麼嗎? 我認爲如果我把這個組件添加到主頁就足夠了。
更新 我asume我在第三級的組件; AppComponent,HomeComponent和CustomerComponent基於此Sample component hierarchy
當您打開瀏覽器控制檯時,您是否看到任何錯誤? – mickdev
不,只有警告但不相關。我期望至少有** CustomerComponent **的頭文件或任何靜態文本。 –