TodoList.ts: @Component({ selector: 'todo-list', directives: [TodoItemRenderer], template: ` <ul> <li *ngFor="#todo of todoService.todos"> <todo-item-renderer [todo]="todo"></todo-item-renderer> </li> <…
angular 使用 @input.@Output 来进行父子组件之间数据的传递. 如下: 父元素: <child-root parent_value="this is parent value" (child_emit)="test()"></child-root> 父元素标签中有一个属性是,parent_value,在子元素中可以使用该值: <p [title]="parent_value" >this p…
custom form control 之前就写过了,这里简单写一下. 创建一个组件实现 ControlValueAccessor 接口 @Component({ providers: [ { provide: NG_VALUE_ACCESSOR, multi: true, useExisting: MyInputComponent }, ], }) export class MyInputComponent implements ControlValueAccessor {} 实现 write…
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…
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 built-in validators such as required or ma…
学习angular,看到 angular-phonecat测试用例,照着教程运行了一遍,对于初学者有点不是很理解angular 帅选代码的意思,于是找教材,参考资料,明白了input筛选原来这么简单. html部分 <!doctype html> <html lang="en" ng-app="listModule"> <head> <meta charset="UTF-8"> <meta n…
<!DOCTYPE html> <html ng-app="app"> <head> <meta charset="UTF-8"> <title></title> <style type="text/css"> .error{ background-color: red; color: #FFF; transition:all linear 0.5s; } .my…
The application is simple, to build a color picker: When click the rect box, it will check the color value below and title color will also change. color-picker.ts: import {Component, Output, EventEmitter, Input} from "@angular/core"; import {RED…
在这一步中您将学到如何创建您自己的展示过滤器. ·在先前的步骤中,细节页面展示“true”或“false”来显示某部电话是否有某项功能.在这一步中,我们将使用自定义的过滤器来将这些个字符串转化成符号:✓ 代表“true”, ✘代表“false”. 让我们看看过滤器代码看起来是什么样的. 最重要的改变展示如下,您可以点击这里在GitHub上查看全部的不同. checkmark过滤器 由于这个过滤器是大众化的(比如:它没有指向任何视图或组件),我们打算将其在一个core模块中注册,该模块包含了“广泛…
old import { Injectable } from '@angular/core'; import { BehaviorSubject } from 'rxjs'; @Injectable({ providedIn: 'root' }) export class DataService { private dataSource = new BehaviorSubject(Object); public currentData = this.dataSource.asObservable…