I have bunch of Angular modules written in JavaScript and would like to import them into TypeScript. I tried using import and require, but it doesn't find my angular module since import checks for TypeScript Modules only.
import myModule= require('myModule');
Is there any other way to do this instead of converting my Js in TypeScript?
You cannot use modules defined using angular.module('my', [])
directly from TypeScript. Such notation is used just to register a module inside internal angularJS object. From good code prospective you have to redesign your angular modules to TypeScript/CommonJS/AMD modules and re-use them in your angular application. But you can go another way:
div
element.angular.element(document.getElementById('myhiddendiv')).injector.invoke(function(YourService: any) { YouService.doDirtyJob(); })
.But I would recommend to go with the first option.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments