[AngularJS] Angular1.3 ngAria - 1
Accessibility is an often overlooked essential feature of a web application. a11y Is a critical component of your AngularJS application. It should be considered early in an applications life. The ng-aria module gets you started quickly, adding instant upgrades to your Angular app's accessibility.
Want to learn more about accessibility and AngularJS? Check out this great talk:AngularJS Accessibility by Marcy Sutton at ng-europe 2014.
Read More: http://jsbin.com/jopex/2/edit
HTML CSS JS Result
Edit on
<html>
<head> <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.0/angular.min.js"></script> <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.0/angular-aria.js"></script>
<script src="app.js"></script>
<title>Egghead Lesson by kentcdodds</title>
</head>
<body ng-app="app" ng-controller="MainCtrl as vm">
<h1>Angular version: {{vm.angularVersion}}</h1>
<h2>
{{vm.lessonTitle || 'Angular Lesson'}}
<small>by <a href="http://twitter.com/kentcdodds">@kentcdodds</a></small>
</h2>
<hr /> <h2>Demo</h2> <form ng-init="vm.radio='1'">
Input Email:<br /><input type="email" show-attrs ng-model="vm.input" />
Textarea:<br /><textarea show-attrs ng-model="vm.textarea"></textarea> Radio:<br />
<input name="myRadio" show-attrs type="radio" ng-model="vm.radio" value="1" />
<input name="myRadio" show-attrs type="radio" ng-model="vm.radio" value="2" /> Checkbox:<br /><input show-attrs type="checkbox" ng-model="vm.checkbox" />
Range:<br /><input show-attrs type="range" ng-model="vm.range" min="0" max="25" />
Hide/Show:<input type="checkbox" ng-model="vm.show" /><input show-attrs ng-show="vm.show" ng-model="hidden" />
Invalid:<br /><input show-attrs type="email" ng-model="vm.email" />
Required:<br /><input show-attrs ng-model="vm.required" required />
Disabled:<input type="checkbox" ng-model="vm.disable" /><br /><button show-attrs type="submit" ng-disabled="vm.disable">Submit</button>
</form> </body>
</html>
/**
* Created by Answer1215 on 11/14/2014.
*/
var app = angular.module('app', ['ngAria']); app.controller('MainCtrl', function MainCtrl() {
'use strict';
var vm = this;
vm.angularVersion = angular.version.full;
vm.lessonTitle = 'How to use the ngAria module'; }); app.directive('showAttrs', function() {
return function(scope, el, attrs) {
var pre = document.createElement('pre');
el.after(pre);
scope.$watch(function() {
var attrs = {};
Array.prototype.slice.call(el[0].attributes, 0).forEach(function(item) {
if (item.name !== 'show-attrs') {
attrs[item.name] = item.value;
}
});
return attrs;
}, function(newAttrs, oldAttrs) {
pre.innerText = JSON.stringify(newAttrs, null, 2);
}, true);
}
});
Also in angular.config(), you can use $ariaProvider to disable some aria value:
- ariaHidden –
{boolean}
– Enables/disables aria-hidden tags - ariaChecked –
{boolean}
– Enables/disables aria-checked tags - ariaDisabled –
{boolean}
– Enables/disables aria-disabled tags - ariaRequired –
{boolean}
– Enables/disables aria-required tags - ariaInvalid –
{boolean}
– Enables/disables aria-invalid tags - ariaMultiline –
{boolean}
– Enables/disables aria-multiline tags - ariaValue –
{boolean}
– Enables/disables aria-valuemin, aria-valuemax and aria-valuenow tags - tabindex –
{boolean}
– Enables/disables tabindex tags
var app = angular.module('app', ['ngAria'])
.config(function($ariaProvider){
$ariaProvider.config({
ariaInvalid: true
})
});
[AngularJS] Angular1.3 ngAria - 1的更多相关文章
- Directive Controller And Link Timing In AngularJS
I've talked about the timing of directives in AngularJS a few times before. But, it's a rather compl ...
- 说说Angular中的$timeOut定时器
非常不幸的一点是,人们似乎常常将AngularJS中的$timeOut()函数看做是一个内置的.无须在意的函数.但是,如果你忘记了$timeOut()的回调函数将会造成非常不好的影响,你可能会因此遇 ...
- browser-sync & http server
browser-sync & http server browser-sync https://www.browsersync.io/ usage # step 1 $ npm install ...
- $timeout()定时器
非常不幸的一点是,人们似乎常常将AngularJS中的$timeOut()函数看做是一个内置的.无须在意的函数.但是,如果你忘记了$timeOut()的回调函数将会造成非常不好的影响,你可能会因此遇到 ...
- [AngularJS] Angular 1.3 ngAria - 2
This is an highlight about ngAira in Angular Document abou ngAira Where can use ngAria? Currently, n ...
- Angular企业级开发(1)-AngularJS简介
AngularJS介绍 AngularJS是一个功能完善的JavaScript前端框架,同时是基于MVC(Model-View-Controller理念的框架,使用它能够高效的开发桌面web app和 ...
- AngularJS的基础元素应用
<!doctype html> <!-- 标记ng-app告诉AngularJS处理整个HTML页并引导应用 --> <html ng-app> <head& ...
- angular1.x的简单介绍 (一)
angular1.x作为经典的mvc框架,可以创建能够复用的组件,也可进行双向数据绑定.国内的vue.js/avaloon.js都是同类型的框架.适合使用angularjs的项目有大型信息化管理系统: ...
- 带你走近AngularJS - 基本功能介绍
带你走近AngularJS系列: 带你走近AngularJS - 基本功能介绍 带你走近AngularJS - 体验指令实例 带你走近AngularJS - 创建自定义指令 ------------- ...
随机推荐
- Linux命令之usermod
usermod [选项] 登录名 usermod修改用户基本信息. (1).常用选项 -d,--home HOME_DIR 用户的新主目录 -g,--gid GROUP 强制GROUP为新主组 -G, ...
- Failed to resolve directive: el vue2报错
vue2报错 Failed to resolve directive: el 为什么会报这个错呢,主要还是因为vue升级的时候,v-el在vue2.x以后被淘汰.使用新的标签ref替换v-el,接下来 ...
- redis_NoSql数据库四大分类
前面简单介绍了什么是NoSql,以及NoSql的应用场景,今天简单来学习一下NoSql的分类 一.KV键值对 典型的介绍:新浪(BerkeleyDB+redis).美团(redis+tair).阿里, ...
- Nginx日志切割工具——logrotate 使用记录
1.安装 logrotate是Linux系统自带,无需安装 2.配置 进入[/etc/logrotate.d/nginx]文件修改配置 # 需要备份的日志路劲,一个或多个都可以 /data/logs/ ...
- Java的运行机制概括
这次随笔主要记录一下我对Java的平台无关性一些新的理解,以前只知道是Java是一门很容易跨平台的语言,正如 "Compile once, run anywhere" 这句话,也知 ...
- poj 2001 trie
第一道trie 还需要写题来建立自己的代码习惯. #include <cstdio> #include <vector> #include <algorithm> ...
- php 导出excel
<?phpclass Excel { var $inEncode; var $outEncode; public function _construct() { } public functio ...
- April Fools Day Contest 2016 E. Out of Controls
E. Out of Controls 题目连接: http://www.codeforces.com/contest/656/problem/E Description You are given a ...
- myBatis 切换数据源(spring事务)理解
1. mybatis (SqlSessionTemplate)的动态代理 a) sqlSession的结构 b)SqlSession 结构 public class SqlSessionTemplat ...
- ubuntu 关闭n卡
ubuntu对n卡支持不好,电脑耗电和发汤,把它关闭掉 #sudo add-apt-repository ppa:bumblebee/stable#sudo apt-get update#su ...