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. nginx 的编译安装及基本操作

    下载nginx [root@nginx ~]# wget http://nginx.org/download/nginx-1.14.0.tar.gz --2019-05-02 21:52:23-- h ...

  2. 包含绑定变量的sql进行调优需注意一点

    拿1个sql举个例子,我只贴出了where后面部分 实际环境中有init_date 和direct_no的组合索引IDX_DATE_NO 上诉标红处,:b3=0 和:b3<>0这两种情况o ...

  3. rfcn讲解博客

    http://www.cnblogs.com/lillylin/p/6277094.html ROI pooling操作的输入(对于C+1个类)是k^2*(C+1)*W' *H'(W'和H'是ROI的 ...

  4. install mysql at linux

    cd /usr/local wget http://repo.mysql.com//mysql57-community-release-el7-7.noarch.rpm rpm -ivh mysql5 ...

  5. My Friends

    HMQ's blog RMY's blog Shq's blog wjyyy‘s blog

  6. c++的if语句中的110为什么不等于110?

    从上图可以看出,当表达式1.1*x被直接放进if的判断括号中时1.1*x不等于y,但是将1.1*x赋值给z时,z与y相等,这是为什么?(以下为不等价时的代码) #include<stdio.h& ...

  7. kvm中内存过载使用

    与CPU过载使用类似,在KVM中内存也是允许过载使用(over commit)的,KVM能够让分配给客户机的内存总数大于实际可用的物理内存总数. 由于客户机操作系统及其上的应用程序并非一直100%地利 ...

  8. cobbler 无人值守-介绍

    cobbler 介绍 快速网络安装linux操作系统的服务,支持众多的Linux版本,也支持网络安装windows系统 PXE的二次封装,将多种安装参数封装到一个菜单 它是由Python编写的 还可以 ...

  9. Django reverse函数

    1.总urls.py内容如下: from django.contrib import admin from django.urls import path from django.conf.urls ...

  10. Activiti流程定义部署方式

    1 bpmn png方式部署 ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine(); /**部署流程定义(从cl ...