[英]es5 to es6 + webpack on angular1 app
I am converting Angular1 to es6 and starting to use webpack. 我正在将Angular1转换为es6并开始使用webpack。 Because of that I need to use 'import/export modules' in all my files.
因此,我需要在我的所有文件中使用“导入/导出模块”。
Do I need to import modules on every file js I have? 我是否需要在每个文件上导入模块? Even the $window of angular for example?
甚至是角度的$窗口? Even on the resolve of a router?
即使在路由器的决心?
I am struggling with the conversion. 我正在努力进行转换。
Is there an easy way to do it on a big app? 有没有一种简单的方法在大型应用程序上执行此操作?
Thanks! 谢谢!
Things like $window, $timeout, $http are imported when you import angular For any other third-party modules you will need to import the file but also inject it into the app module 导入角度时会导入$ window,$ timeout,$ http等内容。对于任何其他第三方模块,您需要导入文件,但也将其注入应用程序模块
Example : 示例:
app.js app.js
import angular from 'angular';
import 'angular-ui-router'; // A third-party npm module
import './controllers/users'; // Custom controller
import config from './config'; // Custom function
import run from './app.run'; // Custom function
const app = angular.module('MyApp', [
'ui.router',
'MyApp.controllers.users'
]);
app.config(config);
app.run(run);
controllers/user.js 控制器/ user.js的
import angular from 'angular';
import '../services/user';
import './modals/users';
const module = angular.module('MyApp.controllers.users', [
'MyApp.services.user',
'MyApp.services.globals',
'MyApp.modals.user',
]);
const UsersController = ($scope, UserService) => {
'ngInject';
$scope.title = 'Users';
$scope.users = UserService.GetAll();
}
module.exports = module.controller('UsersController', UsersController);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.