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:
- create hidden
div
element. - bootstrap angular module want import on div element. here link angularjs documentation may helpful.
- 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
Post a Comment