For example we have a component: <Card ></Card> And a driective: <Card highlighted></Card> We want to get the driective instant inside the component code, we can use @ViewChild: @ViewChild(CardComponennt, {read: HighlightedDirectiv…
angular自定义指令,意我们可以通过angula自己定义指令,来实现我们的特殊要求,为所欲为,一支穿云箭,千军万马来相见 多少年的老规矩了,先看代码: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge&…
angular的GitHub Repository Directive Example学习 <!DOCTYPE html> <html ng-app="myApp"> <head> <meta charset="utf-8" /> <title>GitHub Repository Directive Example</title> <script src="http://cdn.…
Directive究竟是个怎么样的一个东西呢?我个人的理解是这样的:将一段html.js封装在一起,形成一个可复用的独立个体,具体特定的功能.下面我们来详细解读一下Directive的一般性用法. var myDirective = angular.module('directives', []); myDirective.directive('directiveName', function($inject) { return { template: '<div></div>',…
Create a directive to check no special characters allowed: import {Directive, forwardRef} from '@angular/core'; import {AbstractControl, NG_VALIDATORS, Validator} from '@angular/forms'; @Directive({ selector: `[formControl][no-special-chars], [formCo…
---------------------------Scope-------------------------------- https://docs.angularjs.org/guide/scope What are Scopes? Scope is an object(是一个数据模型) that refers to the application model. It is an execution context(scope是表达式的执行上下文) for expressions. Sc…
Also check: directive for form validation User input validation is a core part of creating proper HTML forms. Form validators not only help you to get better quality data but they also guide the user through your form. Angular comes with a series of…
custom form control 之前就写过了,这里简单写一下. 创建一个组件实现 ControlValueAccessor 接口 @Component({ providers: [ { provide: NG_VALUE_ACCESSOR, multi: true, useExisting: MyInputComponent }, ], }) export class MyInputComponent implements ControlValueAccessor {} 实现 write…
AngularJS学习笔记 <!DOCTYPE html> <html ng-app="Demo"> <head> <meta charset="utf-8"> <title></title> </head> <body> <script src="jquery-1.8.3.min.js"></script> <scrip…
官方说明 官方文档 在调用 NgAfterViewInit 回调函数之前就会设置这些视图查询. 元数据属性: selector - 用于查询的指令类型或名字. read - 从查询到的元素中读取另一个令牌. 所支持的选择器包括: 任何带有 @Component 或 @Directive 装饰器的类 字符串形式的模板引用变量(比如可以使用 @ViewChild('cmp') 来查询 <my-component #cmp> 组件树中任何当前组件的子组件所定义的提供商(比如 @ViewChild(S…