Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
58
rated 0 times [  64] [ 6]  / answers: 1 / hits: 26116  / 7 Years ago, thu, july 6, 2017, 12:00:00

I want to import js file in typescript.
And I want to access object and function in the js files.
Also I added js file in index.html but It doesn't working too.
so I find a clue that import '[js file path]' but it doesn't working.



import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { NavParams } from 'ionic-angular';
import '../../pages/mobile.js';


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

export class SuccessPage {
constructor(public navCtrl: NavController, public navParms: NavParams) {

let centerPos = new atlan.maps.UTMK(953933.75, 1952050.75);

}
}


This is success.ts file. I want to find 'atlan' object.
Give me a solution please. Thx a lot!


More From » angular

 Answers
10

You have to use the declare keyword so you do not get any compilation errors. You can do the following



    import { Component } from '@angular/core';
....
/* Here you are telling typescript compiler to
ignore this variable it did not originate with typescript.*/
declare var atlan: any;

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

export class SuccessPage {
....
}

[#57194] Monday, July 3, 2017, 7 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
lara

Total Points: 462
Total Questions: 100
Total Answers: 102

Location: Jersey
Member since Mon, Jun 14, 2021
3 Years ago
lara questions
;