-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Angular1.x + ES6 开发 #6
Comments
使用Webpack打包时,controller的类名被压缩混淆后出错。通过以下方式解决UglifyJsPlugin will change the class.name property /**
* compress js
*/
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
},
mangle: {
except: ['$super', '$', 'exports', 'require', 'angular'],
keep_fnames: true//it works
}
}),
`
|
@heidsoft 这可能是代码问题了,可能需要注入的时候没注入,在打包部署的时候会出错,我举个例子 正确写法 .config(['uiNotificationProvider', uiNotificationProvider => {
uiNotificationProvider.setOptions({
delay: 10000
});
}]) 如果上边代码写成 如下 .config((uiNotificationProvider)=> {
uiNotificationProvider.setOptions({
delay: 10000
});
}) 在热部署(非build)启动,项目是正常的,因为没有压缩,找得到 其他地方类似,需要依赖注入的时候标记明确依赖注入(针对ES6写法) 可参考我的一个工程环境: |
@giscafer 谢谢,我试试 |
@giscafer 比如我想买依赖类似
|
@heidsoft 'use strict'
var accordion = require("./accordion");
var buttons = require("./buttons");
var carousel = require("./carousel");
var collapse = require("./collapse");
var dateparser = require("./dateparser");
var debounce = require("./debounce");
var dropdown = require("./dropdown");
var isClass = require("./isClass");
var modal = require("./modal");
var pager = require("./pager");
var pagination = require("./pagination");
var paging = require("./paging");
var popover = require("./popover");
var position = require("./position");
var progressbar = require("./progressbar");
var rating = require("./rating");
var stackedMap = require("./stackedMap");
var tabindex = require("./tabindex");
var tabs = require("./tabs");
var timepicker = require("./timepicker");
var tooltip = require("./tooltip");
var typeahead = require("./typeahead");
const MODULE_NAME = "demo.app";
angular.module(MODULE_NAME, [accordion,
buttons,
carousel,
collapse,
dateparser,
debounce,
dropdown,
isClass,
modal,
pager,
pagination,
paging,
popover,
position,
progressbar,
rating,
stackedMap,
tabindex,
tabs,
timepicker,
tooltip,
typeahead
]);
export default MODULE_NAME; 上边十多个组件,依赖注入到了模块 |
@giscafer 嗯,你的这些组件是支持commonjs规范的,但是我用的一些js有些没有,比如,bootstrap-table中定义的table指令模块,这时,我用es6 import也是无用的,不知道有什么解决方法
|
@heidsoft 不支持自己改一下就可以了。看有没有UMD判断,比如下边的这些判断 (function (root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module unless amdModuleId is set
define('textAngular', ["rangy","rangy/lib/rangy-selectionsaverestore"], function (a0,b1) {
return (root['textAngular.name'] = factory(a0,b1));
});
} else if (typeof exports === 'object') {
// Node. Does not work with strict CommonJS, but
// only CommonJS-like environments that support module.exports,
// like Node.
module.exports = factory(require("rangy"),require("rangy/lib/rangy-selectionsaverestore"));
} else {
root['textAngular'] = factory(rangy);
}
}(module.exports, function (rangy) {
//……
}) 有这些判断就是支持的,没有你就手动改呀,也简单。网上很多js库一般都支持的(现在不支持的建议都不用哦),也可以下载到现成的 |
Angular 1.x和ES6的结合
xufei/blog#29
Angular1.x + ES6 开发风格指南
kuitos/kuitos.github.io#34
The text was updated successfully, but these errors were encountered: