If we’re going to make our toggle accessible, we’ll need to apply certain aria attributes to the control that does the toggling. Instead of making the parent component handle that, we can provide a toggler directive that automatically applies the needed attributes. Content directives allow the user to tell the UI component where to make those modifications.

<switch toggler [on]="on" (click)="fns.toggle()">
</switch>

We added a toggler directive to share all the common attrs:

import { Directive, HostBinding, Input } from '@angular/core';

@Directive({
selector: '[toggler]'
})
export class TogglerDirective {
@HostBinding('attr.role') role = 'switch'; @HostBinding('attr.aria-checked') @Input() on; constructor() { } }

[Angular] Modify User Provided UI with Angular Content Directives的更多相关文章

  1. 集成 Kendo UI for Angular 2 控件

    伴随着 Angular 2 的正式 release,Kendo UI for Angular 2 的第一批控件已经发布了,当前是 Beta 版本,免费使用. 官方站点:Kendo UI for Ang ...

  2. Kendo UI for Angular 2 控件

    Kendo UI for Angular 2 控件 伴随着 Angular 2 的正式 release,Kendo UI for Angular 2 的第一批控件已经发布了,当前是 Beta 版本,免 ...

  3. [Web UI]对比Angular/jQueryUI/Extjs:没有一个框架是万能的

    Angular不能做什么?对比Angular/jQueryUI/Extjs 框架就好比兵器,你得明白你手里拿的是屠龙刀还是倚天剑,刀法主要是砍,剑法主要是刺.对于那些职业喷子和脑残粉,小僧送你们两个字 ...

  4. Angular项目构建指南 - 不再为angular构建而犹豫不决(转)

    如果你不知道什么是Angular或者根本没听说过,那么我接下来所说的对你来说毫无益处,不过如果你打算以后会接触Angular或者干脆要涨涨姿势~读下去还是有点用的. Angular和它之前所出现的其余 ...

  5. [Angular 2 Router] Configure Your First Angular 2 Route

    Using the Angular 2 router requires defining routes, passing them in to the RouterModule.forRoot and ...

  6. 【Angular专题】——(1)Angular,孤傲的变革者

    目录 一. 漫谈Angular 二. 如果你还在使用Angularjs 三. 我计划这样学习Angular技术栈 一. 漫谈Angular Angular,来自Google的前端SPA框架,与Reac ...

  7. [Angular] Use Angular components in AngularJS applications with Angular Elements

    When migrating AngularJS (v1.x) applications to Angular you have different options. Using Angular El ...

  8. Angular 从入坑到挖坑 - Angular 使用入门

    一.Overview angular 入坑记录的笔记第一篇,完成开发环境的搭建,以及如何通过 angular cli 来创建第一个 angular 应用.入坑一个多星期,通过学习官方文档以及手摸手的按 ...

  9. [从 0 开始的 Angular 生活]No.38 实现一个 Angular Router 切换组件页面(一)

    前言 今天是进入公司的第三天,为了能尽快投入项目与成为团队可用的战力,我正在努力啃官方文档学习 Angular 的知识,所以这一篇文章主要是记录我如何阅读官方文档后,实现这个非常基本的.带导航的网页应 ...

随机推荐

  1. 自己写的画loss曲线代码

    import matplotlib.pyplot as plt iteration = [] loss = [] with open('/home/sensetime/log.txt','r') as ...

  2. 解决chrome 批量下载器 mgblihnaaedmhhgadafknogahbgejnno 插件乱码

    找到 mgblihnaaedmhhgadafknogahbgejnno\当前版本号(0.0.1_0)\popup.html <html> <head> <meta cha ...

  3. 简单批处理命令直接启动你的AVD

    大家都知道,要想启动AVD,一般方法是先打开Android SDK and AVDmanager,再选择你要启动的AVD选择start(废话) 那么,有没有一种简单的方法在任何位置一键启动你指定的av ...

  4. 配置maven报错 the java_home environment variable is not defined correctly ......

    the java_home environment variable is not defined correctly This environment variable is needed to r ...

  5. python_装饰器——迭代器——生成器

    一.装饰器 1.什么是装饰器? 器=>工具,装饰=>增加功能 1.不修改源代码 2.不修改调用方式 装饰器是在遵循1和2原则的基础上为被装饰对象增加功能的工具 2.实现无参装饰器 1.无参 ...

  6. Linux 配置yum本地安装源

    cat /etc/system-release Red Hat Enterprise Linux Server release 7.0 (Maipo) 1 使用本地源得先挂载ISO光盘文件 # 可以创 ...

  7. EmpireofCode文档翻译 https://empireofcode.com/game/

    In Campaign mode, you can check your strategies on already defeated bases. You will not lose your tr ...

  8. win7 如何将python加入环境变量

    我的电脑->右键属性->高级->系统变量 path里加上安装路径,比如 ";C:\Python26;" 请加分号附在其他path后面而不是直接覆盖.

  9. js总结(一):javascript的类型:基本类型、对象和数组

    javascript 类型分为2种,一个是原始值,另一个是复杂值(对象). 一.原始值 5个原始值是:数字,字符,布尔,null,undefined. 9个原生的对象构造函数:Number Strin ...

  10. linux基础知识汇总

    1.如何快速回到上次操作的目录? cd - 2.如何快速回到家目录? 直接cd或者cd ~ 3.怎么回到上一级目录? cd .. 4.什么是相对路径,什么是绝对路径? 相对路径就是相对于当前目录的位置 ...