2

I am getting a 'Cannot find name' error when I inject a service into a class by inserting the imported name into the arguments of the constructor. This has happen a few times to me now and I can't figure out what fixes it. Any light shed on this would be much appreciated. Here is my example:

import { Component } from '@angular/core';
import { Injectable } from '@angular/core';
import { Http, Response } from '@angular/http';
import { _ } from 'lodash';
import { RatesService } from '../../services/RatesService';
import { NavController } from 'ionic-angular';
import { Currencies } from '../../models/currencies.ts';

@Component({
    selector: 'page-rates',
    templateUrl: 'rates.html'
})

export class Rates {

constructor(public navCtrl: NavController,
        private ratesService: RatesService,
        private currencies: Currencies) { }
}

'Currencies' causes the error

1 Answer 1

3

The typescript compiler is giving us a misleading error string.

Change:

 import { Currencies } from '../../models/currencies.ts';

to

 import { Currencies } from '../../models/currencies';
Sign up to request clarification or add additional context in comments.

1 Comment

explanation? I thought extension is optional not prohibited

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.