【发布时间】:2021-05-06 00:15:39
【问题描述】:
当我尝试运行我的项目时出现此错误,我尝试在 angularCompilerOptions 中设置 strictPropertyInitialization false 但它也不起作用,我尝试设置!而是酿造
import { HttpService } from '../http.service';
@Component({
selector: 'app-list',
templateUrl: './list.component.html',
styleUrls: ['./list.component.scss']
})
export class ListComponent implements OnInit {
brews: Object;
constructor(private _http: HttpService) { }
ngOnInit() {
this._http.getBeer().subscribe(data => {
this.brews = data
console.log(this.brews);
});
}
}
<h1>Breweries</h1>
<ul *ngIf="brews">
<li *ngFor="let brew of brews">
<p class="name">{{ brew.name }}</p>
<p class="country">{{ brew.country }}</p>
<a class="site" href="{{ brew.website_url }}">site</a>
</li>
</ul>
【问题讨论】:
标签: angular