[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函数(类型/类),用来增强除了根作用域以外的作用域实例的. ...
随机推荐
- DEDECMS 猜你喜欢
dede升级了5.7后,有个地方要求调用相关文章,于是写下 dede:likeart 标签却无法实现关联,显示的则是所有文章. 发现原来从5.5版开始已经替换了该标签,把模板中 likeart ...
- PHPCMS GET标签使用
大纲: get 标签概述get 标签语法get 标签创建工具get 调用本系统示例get 调用其他系统示例一.get 标签概述 通俗来讲,get 标签是Phpcms定义的能直接调用数据库里面内容 ...
- POJ 3041 Asteroids 最小点覆盖 == 二分图的最大匹配
Description Bessie wants to navigate her spaceship through a dangerous asteroid field in the shape o ...
- VS 调试相关
最近用VS2013 调试遇到的一点小问题,老年痴呆做一下记录. 1. IIS 用 w3wp.exe 调试: IIS 中的文件系统与工程的保持一致,否则断点不会命中: 发布文件系统后,重启站点对应的应用 ...
- java答疑
问 什么是 Java 的字节码? 答 它是程序的一种低级表示,可以运行于 Java 的虚拟机.将程序抽象为字节码可以保证 Java 程序员的 代码能够运行在各种设备之上. 问 Java 允许整型溢出并 ...
- hdu 1576 A/B 拓展欧几里得算法
A/B Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submiss ...
- Spring MVC 解读——View,ViewResolver(转)
上一篇文章(1)(2)分析了Spring是如何调用和执行控制器方法,以及处理返回结果的,现在我们就分析下Spring如何解析返回的结果生成响应的视图. 一.概念理解 View ---View接口表示一 ...
- 遍历、显示ftp下的文件夹和文件信息
今天做了通过ftp读取ftp根目录下的所有文件夹和文件,嵌套文件夹查询,总共用到了一下代码: 1.FtpFile_Directory package com.hs.dts.web.ftp; impor ...
- 【HDOJ】4902 Nice boat
区间线段树.题目还不错. /* */ #include <iostream> #include <string> #include <map> #include & ...
- 【HDOJ】3584 Cube
三位树状数组. /* 3584 */ #include <iostream> #include <string> #include <map> #include & ...