我在ngFor下面有一个要删除的c.FilmCode
的前四个字符
<li class="">
<a [(ngModel)]="selectedmovies" ngDefaultControl name="" class="form-control" (click)="togglemovies()" id="cbocmovies" [ngModelOptions]="{standalone: true}">{{selectedmoviestext}}</a>
<div [ngClass]="{toggleMovie:IsToggleMovie==true}" *ngIf="movies.length > 0">
<ul class="clearfix">
<li *ngFor="let c of movies" [value]="c.FilmCode" (click)="OnMoviesChange(c.FilmTitle,c.FilmCode)">{{c.FilmTitle}}</li>
</ul>
</div>
</li>
下面是ts
代码
showmoviecombo(CinemaId) {
this.common.createAPIService('api/cinemas/GetListByCinemaId?CinemaId=' + CinemaId, '').subscribe((result: any) => {
this.movies = result;
//this.movieids = this.movies.FilmCode;
console.log(this.movieids);
});
}
有什么办法吗?
答案 0 :(得分:1)
您还可以使用 Slice 删除前四个字符
<li class="">
<a [(ngModel)]="selectedmovies" ngDefaultControl name="" class="form-control" (click)="togglemovies()" id="cbocmovies" [ngModelOptions]="{standalone: true}">{{selectedmoviestext}}</a>
<div [ngClass]="{toggleMovie:IsToggleMovie==true}" *ngIf="movies.length > 0">
<ul class="clearfix">
<li *ngFor="let c of movies" [value]="c.FilmCode" (click)="OnMoviesChange(c.FilmTitle,c.FilmCode)">{{c.FilmTitle.slice(4)}}</li>
</ul>
</div>
答案 1 :(得分:0)
您可以在字符串值方法上使用substring
<li class="">
<a [(ngModel)]="selectedmovies" ngDefaultControl name="" class="form-control" (click)="togglemovies()" id="cbocmovies" [ngModelOptions]="{standalone: true}">{{selectedmoviestext}}</a>
<div [ngClass]="{toggleMovie:IsToggleMovie==true}" *ngIf="movies.length > 0">
<ul class="clearfix">
<li *ngFor="let c of movies" [value]="c.FilmCode" (click)="OnMoviesChange(c.FilmTitle,c.FilmCode)">{{c.FilmTitle?.substring(4)}}</li>
</ul>
</div>
</li>