0
我正在尝试使用打字稿构建angularjs(angular 1.)项目的结构。 我正在使用webpack将打印稿编码& ES6编译为javascript。如何在打字稿中导入angularjs子模块
在我的项目我配置的WebPack只编译“app.ts”文件,包括在所有其他文件与“进口”的语法:
import { config } from './config';///<--HERE
module angularSeed {
'use strict';
// Declare app level module which depends on views, and components
angular.module('myApp', [
'ngRoute',
'myApp.view1',
'myApp.view2',
'myApp.version'
]).config(config)//<-- using imported config.ts
}
我想我的项目拆分成角子模块并纳入主模块类似以下内容:
angular.module('mainApp',['myApp.version','myApp.view1','myApp.view2'])
的问题是:如何导出子模块?
我迄今为止发现的唯一方法是定义模块定义文件作为类:
class view1 {
constructor(){
angular.module('myApp.view1', ['ngRoute'])
.config(['$routeProvider', ($routeProvider: angular.route.IRouteProvider) => {
$routeProvider.when('/view1', {
templateUrl: 'view1/view1.html',
controller: 'View1Ctrl'
});
}])
.controller('View1Ctrl', [() => {
}]);
}
}
export default view1;
,并在主文件 - 使用“新的”火的构造:
import { config } from './config';
import view2 from './view2/view2';
import view1 from './view1/view1';
import version from './components/version/version';
module angularSeed {
'use strict';
new view2();///<-- HERE
new view1();
new version();
// Declare app level module which depends on views, and components
angular.module('myApp', [
'ngRoute',
'myApp.view1',
'myApp.view2',
'myApp.version'
]).config(config)
}
我有感觉有更准确的方法。 对吗?
感谢