[AngularJS + Webpack] Requiring Templates
With Angular, most of the time you're specifying a templateUrl for your directives and states/routes. This means you need to make sure that you're loading in these templates into the $templateCache for your tests and production. Oh, and don't forget to update all your URLs whenever you move the files around! When you add in Webpack and the html-loader, you don't need to do this anymore. Simply require the html file and your work is done!
Install:
npm install -D html-loader
webpack.config.js:
module.exports = {
entry: {
app: ['./app/index.js']
},
output: {
path: './build',
filename: 'bundle.js'
},
module: {
loaders: [
{test: /\.js$/, loader: 'babel-loader', exclude: /node_modules/},
{test: /\.html$/, loader: 'html-loader', exclude: /node_modules/}
]
}
};
hello.js:
export default (ngModule) => {
ngModule.directive('hello', () => {
return {
restrict: 'E',
scope: {},
template: require('./hello.html'),
controllerAs: 'vm',
controller: function() {
var vm = this;
vm.greeting = "Hello";
}
}
})
}
[AngularJS + Webpack] Requiring Templates的更多相关文章
- [AngularJS + Webpack] Requiring CSS & Preprocessors
Making your CSS modular is a difficult thing to do, but using Webpack makes this so much easier. By ...
- [AngularJS + Webpack] require directives
direictives/index.js: module.exports = function(ngModule) { //register all the directives here requi ...
- [AngularJS + Webpack] Using Webpack for angularjs
1. Install webpack & angular: npm install webpack angular 2. Create webpack.config.js file: modu ...
- [AngularJS + Webpack] Uglifying your JavaScript
Angular requires some careful consideration when uglifying your code because of how angular's depend ...
- [AngularJS + Webpack] Production Setup
Using Angular with webpack makes the production build a breeze. Simply alter your webpack configurat ...
- [AngularJS + Webpack] ES6 with BabelJS
Install: npm install --save-dev babel-loader webpack.config.js: Add module, tell webpack to find all ...
- 虽然今天angular5发布了,但我还是吧这篇angularjs(1)+webpack的文章发出来吧哈哈哈
本文为原创,转载请注明出处: cnzt 文章:cnzt-p http://www.cnblogs.com/zt-blog/p/7779384.html 写在前面: 因为最近总结自己之前做过 ...
- AngularJS开发指南11:AngularJS的model,controller,view详解
model model这个词在AngularJS中,既可以表示一个(比如,一个叫做phones的model,它的值是一个包含多个phone的数组)对象,也可以表示应用中的整个数据模型,这取决于我们所讨 ...
- Angularjs之controller 和filter(四)
Controller组件(http://www.angularjs.cn/A00C) 在AngularJS中,控制器是一个Javascript函数(类型/类),用来增强除了根作用域以外的作用域实例的. ...
随机推荐
- Laravel框架——分页
第一种:查询时实现分页(不能使用groupBy) $users = App\User::paginate(15); or $users = User::where('votes', '>', 1 ...
- Quartz源码阅读
基于Quartz1.8.5的源码解读 首先看一个demo //简单的任务管理类 //QuartzManager.java package quartzPackage; import java.text ...
- Nginx配置免费SSL证书StartSSL,解决Firefox不信任问题
先在StartSSL上申请免费一年的SSL证书,具体过程网上很多教程.然后把申请到的key和crt文件上传到服务器,比如/usr/local/nginx/certs/. Nginx配置SSL证书 直接 ...
- [HDOJ 5183] Negative and Positive (NP) 【Hash】
题目链接:HDOJ - 5183 题目分析 分两种情况,奇数位正偶数位负或者相反. 从1到n枚举,在Hash表中查询 Sum[i] - k ,然后将 Sum[i] 加入 Hash 表中. BestCo ...
- java 伪共享
MESI协议及RFO请求典型的CPU微架构有3级缓存, 每个核都有自己私有的L1, L2缓存. 那么多线程编程时, 另外一个核的线程想要访问当前核内L1, L2 缓存行的数据, 该怎么办呢?有人说可以 ...
- /etc/shadow字段详解
1)/etc/shadow 概说: /etc/shadow文件是/etc/passwd 的影子文件,这个文件并不由/etc/passwd 而产生的,这两个文件是应该是对应互补的:shadow内容包括用 ...
- h.264并行解码算法分析
并行算法类型可以分为两类 Function-level Decomposition,按照功能模块进行并行 Data-level Decomposition,按照数据划分进行并行 Function-le ...
- 嵌入式C语言头文件的建立与使用
如何正确编写 C 语言头文件和与之相关联的 c 源程序文件,这首先就要了解它们的各自功能. 要理解 C 文件与头文件(即.h)有什么不同之处,首先需要弄明白编译器的工作过程. 一般说来编译器会做以下几 ...
- 解决VS2005 VS2008 vs2010断点无效-源代码与原始版本不同
网上说的方法:(额~但是我就是不能用.但是也贴出来) 方法1.直接把整个文件格式化了一次,断点就可以用了Ctrl + A全选菜单:编辑-〉高级-〉设置选定内容的格式 (Ctrl+K, Ctrl+F)通 ...
- _CrtSetBreakAlloc简单内存泄漏检测方法,解决Detected memory leaks!问题
我的环境是: XP SP2 . VS2003 最近在一个项目中,程序退出后都出现内存泄漏: Detected memory leaks! Dumping objects -> {98500} n ...