Angular ng-repeat 不起作用,但我能够单独显示数组元素
Angular ng-repeat doesn't work, but I'm able to display array elements individually
问题:我无法看到我尝试使用 ng-repeat
.
打印的任何字符串数组元素
组件:
import {
Component
} from '@angular/core';
@Component ({
selector: 'my-app',
templateUrl: 'app/app.component.html'
})
export class AppComponent {
TutorialName: string = 'Angular JS2';
appList: string[] = ["Binding", "Display", "Services"];
currentTime = new Date();
}
模板:
<div>
The first item is {{appList[0] }}<br>
The first item is {{appList[0] | lowercase}} (lowercase)<br>
The first item is {{appList[0] | uppercase}} (uppercase)<br>
The second item is {{appList[1] }}<br>
The items are:
<ol>
<li ng-repeat="a in appList">{{a}}</li>
</ol>
The date/time is: {{currentTime}}<br>
The date/time is: {{currentTime | date:'MM/dd/yyyy'}} (date:'MM/dd/yyyy')<br>
</div>
所有内容都显示 find except {{a}}。
问:访问字符串数组 "appData" 以便使用 "ng-repeat" 正确打印项目的正确方法是什么?
ANGULAR 版本:
Angular CLI: 7.0.5
Node: 11.1.0
OS: linux x64
Angular:
...
Package Version
------------------------------------------------------
@angular-devkit/architect 0.10.5
@angular-devkit/core 7.0.5
@angular-devkit/schematics 7.0.5
@schematics/angular 7.0.5
@schematics/update 0.10.5
rxjs 6.3.3
typescript 3.1.6
Angular 不再使用 ng-repeat
,这是在 Angular 从 AngularJS 移动到仅 Angular Angular 1.X --> Angular 2+
[= 时更新的17=]
使用 *ngFor
而不是像这样使用相同的方式...
<ol>
<li *ngFor="let a of appList">{{a}}</li>
</ol>
您可以阅读从 ng-repeat
到 *ngFor
here
的变化
问题:我无法看到我尝试使用 ng-repeat
.
组件:
import {
Component
} from '@angular/core';
@Component ({
selector: 'my-app',
templateUrl: 'app/app.component.html'
})
export class AppComponent {
TutorialName: string = 'Angular JS2';
appList: string[] = ["Binding", "Display", "Services"];
currentTime = new Date();
}
模板:
<div>
The first item is {{appList[0] }}<br>
The first item is {{appList[0] | lowercase}} (lowercase)<br>
The first item is {{appList[0] | uppercase}} (uppercase)<br>
The second item is {{appList[1] }}<br>
The items are:
<ol>
<li ng-repeat="a in appList">{{a}}</li>
</ol>
The date/time is: {{currentTime}}<br>
The date/time is: {{currentTime | date:'MM/dd/yyyy'}} (date:'MM/dd/yyyy')<br>
</div>
所有内容都显示 find except {{a}}。
问:访问字符串数组 "appData" 以便使用 "ng-repeat" 正确打印项目的正确方法是什么?
ANGULAR 版本:
Angular CLI: 7.0.5
Node: 11.1.0
OS: linux x64
Angular:
...
Package Version
------------------------------------------------------
@angular-devkit/architect 0.10.5
@angular-devkit/core 7.0.5
@angular-devkit/schematics 7.0.5
@schematics/angular 7.0.5
@schematics/update 0.10.5
rxjs 6.3.3
typescript 3.1.6
Angular 不再使用 ng-repeat
,这是在 Angular 从 AngularJS 移动到仅 Angular Angular 1.X --> Angular 2+
[= 时更新的17=]
使用 *ngFor
而不是像这样使用相同的方式...
<ol>
<li *ngFor="let a of appList">{{a}}</li>
</ol>
您可以阅读从 ng-repeat
到 *ngFor
here