zoukankan      html  css  js  c++  java
  • [Angular] Modify User Provided UI with Angular Content Directives

    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() { }
    
    }
  • 相关阅读:
    C#生成唯一码方法
    解剖常用软件程序都用什么语言开发
    Unity3D笔记七 GUILayout
    函数的递归
    函数
    函数的参数
    函数的返回值
    函数的定义
    文件处理
    集合
  • 原文地址:https://www.cnblogs.com/Answer1215/p/9768361.html
Copyright © 2011-2022 走看看