AngularCSS 的引入: CSS On-Demand for AngularJS
1) Include the required JavaScript libraries in your index.html
(ngRoute and UI Router are optional). 引入
- <script src="/libs/angularjs/1.5.6/angular.min.js"></script>
- <script src="/libs/angularjs/1.5.6/angular-routes.min.js"></script>
- <script src="/libs/angular-css/angular-css.min.js"></script>
You can download AngularCSS from GitHub. Also available via Bower and CDN.
2. Add angularCSS
as a dependency for your app. 配置
- var myApp = angular.module('myApp', ['ngRoute','angularCSS']);
3.Examples
In Components
- myApp.component('myComponent', {
- css: 'my-component/my-component.css' // <--- magic!
- templateUrl: 'my-component/my-component.html',
- });
In Directives
- myApp.directive('myDirective', function () {
- return {
- restrict: 'E',
- templateUrl: 'my-directive/my-directive.html',
- /* Binding css to directives */
- css: 'my-directive/my-directive.css'
- }
- });
In Controllers
- myApp.controller('pageCtrl', function ($scope, $css) {
- // Binds stylesheet(s) to scope create/destroy events (recommended over add/remove)
- $css.bind({
- href: 'my-page/my-page.css' // 该路径为文件所在路径
- }, $scope);
- // Simply add stylesheet(s)
- $css.add('my-page/my-page.css');
- // Simply remove stylesheet(s)
- $css.remove(['my-page/my-page.css','my-page/my-page2.css']);
- // Remove all stylesheets
- $css.removeAll();
- });
For Routes (Angular's ngRoute)
Requires ngRoute as a dependency
- myApp.config(function($routeProvider) {
- $routeProvider
- .when('/page1', {
- templateUrl: 'page1/page1.html',
- controller: 'page1Ctrl',
- /* Now you can bind css to routes */
- css: 'page1/page1.css'
- })
- .when('/page2', {
- templateUrl: 'page2/page2.html',
- controller: 'page2Ctrl',
- /* You can also enable features like bust cache, persist and preload */
- css: {
- href: 'page2/page2.css',
- bustCache: true
- }
- })
- .when('/page3', {
- templateUrl: 'page3/page3.html',
- controller: 'page3Ctrl',
- /* This is how you can include multiple stylesheets */
- css: ['page3/page3.css','page3/page3-2.css']
- })
- .when('/page4', {
- templateUrl: 'page4/page4.html',
- controller: 'page4Ctrl',
- css: [
- {
- href: 'page4/page4.css',
- persist: true
- }, {
- href: 'page4/page4.mobile.css',
- /* Media Query support via window.matchMedia API
- * This will only add the stylesheet if the breakpoint matches */
- media: 'screen and (max-width : 768px)'
- }, {
- href: 'page4/page4.print.css',
- media: 'print'
- }
- ]
- });
- });
相关链接参考:
https://github.com/castillo-io/angular-css(github源码)
http://door3.com/insights/introducing-angularcss-css-demand-angularjs#.V-CKT5FJIdZ(Introducing AngularCSS: CSS On-Demand for AngularJS)
http://www.ituring.com.cn/tupubarticle/1385(第 11 章 AngularJS模块加载)
AngularCSS 的引入: CSS On-Demand for AngularJS的更多相关文章
- CSS系列:在HTML中引入CSS的方法
HTML与CSS是两个作用不同的语言,它们同时对一个网页产生作用,因此必须将CSS与HTML链接在一起使用.在HTML中,引入CSS的方法主要有4种:行内式.内嵌式.导入式和链接式. 1. 行内式 行 ...
- Spring MVC:在jsp中引入css
为了将css引入jsp中,今天可真是踩了好多坑,最后在stackoverflow上找到了解决方法,不多说贴出代码. 在web.xml中添加以下代码: <servlet-mapping> & ...
- html引入css文件
在HTML中,引入CSS的方法主要有行内式.内嵌式.导入式和链接式. 行内式:即在标记的style属性中设定CSS样式,这种方式本质上没有体现出CSS的优势,因此不推荐使用.例: <html&g ...
- 引入CSS
前面的话 Web早期,HTML是一种很有限的语言,这种语言不关心外观,它只是一种简洁的小型标记机制.随着Mosaic网页浏览器的出现,网站开始到处涌现.对于页面改变外观的需求增加,于是增加了类似< ...
- jquery,js引入css文件,js引入头尾
jquery,js引入css文件,js引入头尾 今天在项目中,需要把20多个页面加上头和尾部,头和尾是我写的,所以小师傅把这个工作交给我了. 我开始往里面加,先引入common.css,在body开始 ...
- 引入css外部样式表
前言 为什么会有这篇文章,外部引入样式有什么好谈的,不外乎就是 <link rel="stylesheet" href="style.css" /> ...
- 引入css ,使用@import和link的方式
我们也经常听到有人说要使用link来引入CSS更好,但是你知道为什么吗? 继续往下看 linklink就是把外部CSS与网页连接起来. @importimport文字上与link的区别就是它可以把在一 ...
- 引入CSS文件的方式,以及link与@import的区别
一.引入css的方式 在HTML中引入css的方法主要有4种:行内式.内嵌式.链接式和导入式. 1.行内式 <div style="background:yellow;"&g ...
- vue脚手架使用swiper /引入js文件/引入css文件
1.安装vue-cli 参考地址:https://github.com/vuejs/vue-cli 如果不使用严格语法需要在后三项打no:(加了挺头疼的,老是报错,但是对自己的代码规范性也是有很大的帮 ...
- HTML中引入CSS的方法
在HTML中引入CSS的方法主要有四种,它们分别是行内式.内嵌式.链接式和导入式. 1.行内式 行内式是在标记的style属性中设定CSS样式.这种方式没有体现出CSS的优势,不推荐使用. 2.内嵌式 ...
随机推荐
- 【博弈论】【SG函数】bzoj1457 棋盘游戏
一开始就必胜的特判一下. #include<cstdio> #include<cstring> #include<set> #include<algorith ...
- 【kmp算法】模板
void GetFail(char P[],int __next[])//__next[i]表示s[0]~s[i-1]的前缀中,最大长度相等的前后缀是多少 { __next[0]=-1; int le ...
- 【贪心】【二维偏序】【权值分块】bzoj1691 [Usaco2007 Dec]挑剔的美食家
既然题目中的要求满足二维偏序,那么我们很自然地想到将所有东西(草和牛)都读进来之后,对一维(美味度)排序,然后在另一维(价值)中取当前最小的. 于是,Splay.mutiset.权值分块什么的都支持查 ...
- JavaScript的=、==和===
(1) 百度知道上的解释: = 为对象赋值 == 表示两个对象toString值相等 === 表示两个对象类型相同且值相等 (2) 知乎上的解释: 绝大多数场合应该使用 === ,只有检测 null ...
- windbg --sqlserver 实例 转
http://blog.csdn.net/obuntu/article/details/5962378 SQLSERVER DUMP 调试 在下面的对话框输入 ~ 会出现线程的信息 0:000> ...
- TELNET终端类型选项
转:http://www.cnpaf.net/Class/Telnet/200408/5.html 1. 命令名称及编号TERMINAL-TYPE242.命令含义IACWILLTERMINAL-TYP ...
- oracle审计AUD$过大导致的数据库登录异常
今天,省分技术人员反映数据库登录异常. 查询oerr,发现该错误是一般性提示,可能导致的原因有数据库未注册.本地文件配置问题等.由于平时连接并没有问题,是突发情况,所以排除了配置问题. 远程登录查 ...
- ASP.NET MVC DropdownList的使用
1:直接使用HTML代码写 <select name="year"> <option value="2011">2010</opt ...
- 基于CentOS与VmwareStation10搭建Oracle11G RAC 64集群环境:3.安装Oracle RAC-3.1.安装并配置ASM驱动
3.1.安装并配置ASM驱动 3.3.1.检查内核 [root@linuxrac2 etc]# uname -r 2.6.18-164.el5 下载以下rpm包(注意rpm包版本和Linux内核版本一 ...
- Linux的PCI驱动分析
1. 关键数据结构 PCI设备上有三种地址空间:PCI的I/O空间.PCI的存储空间和PCI的配置空间.CPU可以访问PCI设备上的所有地址空间,其中I/O空间和存储空间提供给设备驱动程序使用,而配置 ...