如何将其转换为正确的TypeScript(Angular2)?
import { UtilsService } from '../providers/utils-service';
@Injectable()
export class ImagesService {
constructor(
private connectionStatus: ConnectionStatus
, private UrlExists: UrlExists
, private storageService: LocalStorageService
, private UtilsService: UtilsService
) {
}
usualTreatment(prodata, gotANewDB) {
if (str.indexOf(suffix, this.length - suffix.length) === -1) {
...
因为我收到范围错误:
Typescript Error
Property 'length' does not exist on type 'ImagesService'.
src/providers/images-service.ts
for (var str in imagesUrls) {
if (str.indexOf(suffix, this.length
答案 0 :(得分:1)
我认为你的意思是
if (str.indexOf(suffix, str.length - suffix.length) === -1) {
^^^