angularjs - Import Angular JavaScript Modules into TypeScript -


i have bunch of angular modules written in javascript , import them typescript. tried using import , require, doesn't find angular module since import checks typescript modules only.

import mymodule= require('mymodule'); 

is there other way instead of converting js in typescript?

you cannot use modules defined using angular.module('my', []) directly typescript. such notation used register module inside internal angularjs object. code prospective have redesign angular modules typescript/commonjs/amd modules , re-use them in angular application. can go way:

  1. create hidden div element.
  2. bootstrap angular module want import on div element. here link angularjs documentation may helpful.
  3. use next snippet use service or whatewer else registered in module: angular.element(document.getelementbyid('myhiddendiv')).injector.invoke(function(yourservice: any) { youservice.dodirtyjob(); }).

but recommend go first option.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -