我正在进行API调用并存储一堆用户配置文件,我希望能够为每个配置文件动态创建卡(Angular Material Design md-card).返回的配置文件数量可能不同,因此需要是动态的.
这是我的组件文件,它生成JSONP请求并将配置文件存储在profiles变量中:
import {Component, Injectable, OnInit} from '@angular/core';
import {Jsonp} from '@angular/http';
@Component({
selector: 'app-staff',
templateUrl: './staff.component.html',
styleUrls: ['./staff.component.css']
})
@Injectable()
export class StaffComponent implements OnInit {
public searchField: string;
apiRoot = 'this/is/my/api/url';
public results: JSON;
public profiles;
constructor(private jsonp: Jsonp) {
}
ngOnInit() {
}
setSearchField(field: string){ // ignore this method
this.searchField = field;
console.log('Received field: ' + this.searchField);
}
search(term: string) {
const apiUrl = `${this.apiRoot}?search=${term}&rows=10&callback=JSONP_CALLBACK`;
return this.jsonp.request(apiUrl).map(results => { this.results = results.json(); …Run Code Online (Sandbox Code Playgroud) 遇到angular-aria模块时,我一直在组件模板中手动包括ARIA属性:https : //docs.angularjs.org/api/ngAria
但是,这是针对AngularJS的。Angular 2和4是否有任何等效的模块在运行时以静默方式将aria属性注入组件?
我看了这个问题:如何在Angular 2应用程序中包含ngAria?但它似乎没有答案。