随笔分类 -  Angular

上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 23 下一页
摘要:Using factory provider: Here we create 'DrinkFactory' as a named funciton, this is good for AOT, so recommended doing this way. 阅读全文
posted @ 2017-05-11 04:04 Zhentiw 阅读(1235) 评论(0) 推荐(0)
摘要:Previously we have 'OpaqueToken', but it is DEPRECATED. The new one is called 'InjectionToken'. The difference between OpaqueToken is for InjectionTok 阅读全文
posted @ 2017-05-11 01:35 Zhentiw 阅读(907) 评论(0) 推荐(0)
摘要:directive: test: 阅读全文
posted @ 2017-05-10 02:27 Zhentiw 阅读(387) 评论(0) 推荐(0)
摘要:For example, when testing container component we might import lots of children components, but we didn't actually testing those children components. S 阅读全文
posted @ 2017-05-09 23:54 Zhentiw 阅读(771) 评论(0) 推荐(0)
摘要:The main idea for testing contianer component is to make sure it setup everythings correctlly. Call the onInit() lifecycle first, then the variables h 阅读全文
posted @ 2017-05-09 23:49 Zhentiw 阅读(318) 评论(0) 推荐(0)
摘要:Component: Test: 阅读全文
posted @ 2017-05-09 23:16 Zhentiw 阅读(668) 评论(0) 推荐(0)
摘要:Component: Test @Input & @Output: 阅读全文
posted @ 2017-05-06 03:33 Zhentiw 阅读(313) 评论(0) 推荐(0)
摘要:component: 阅读全文
posted @ 2017-05-03 15:03 Zhentiw 阅读(322) 评论(0) 推荐(0)
摘要:import { Http, Response, ResponseOptions } from '@angular/http'; import { TestBed } from '@angular/core/testing'; import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/... 阅读全文
posted @ 2017-05-03 14:50 Zhentiw 阅读(257) 评论(0) 推荐(0)
摘要:import { TestBed, ComponentFixture } from '@angular/core/testing'; import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing'; import { Fil... 阅读全文
posted @ 2017-04-30 22:41 Zhentiw 阅读(230) 评论(0) 推荐(0)
摘要:import { Pipe, PipeTransform } from '@angular/core'; @Pipe({ name: 'filesize' }) export class FileSizePipe implements PipeTransform { transform(size: number, extension: string = 'MB') { retu... 阅读全文
posted @ 2017-04-30 15:53 Zhentiw 阅读(273) 评论(0) 推荐(0)
摘要:Define a auxilliary router: HTML: Routing by routerLink: Clean auxiliary router: Routing by JS: RouterLink's advantage: Angular will convert routerLin 阅读全文
posted @ 2017-04-27 03:16 Zhentiw 阅读(348) 评论(0) 推荐(0)
摘要:export class MailFolderComponent implements OnInit{ title: Observable; messages: Observable; constructor( private route: ActivatedRoute ){ } ngOnInit() { this.messages = thi... 阅读全文
posted @ 2017-04-26 03:35 Zhentiw 阅读(512) 评论(0) 推荐(0)
摘要:For example, we have a component which just simply render router-outlet: We can add events to router-outlet: When we log out the, we see the actual co 阅读全文
posted @ 2017-04-25 03:08 Zhentiw 阅读(575) 评论(0) 推荐(0)
摘要:In our root component, one thing we can do is subscribe to Router events, and do something related to router events. So how can we get router event? T 阅读全文
posted @ 2017-04-25 02:54 Zhentiw 阅读(911) 评论(0) 推荐(0)
摘要:To enable router tracing is really simple: When we define the root RouterModule, we can pass the option "enableTracing". What we you get is when we na 阅读全文
posted @ 2017-04-25 02:45 Zhentiw 阅读(652) 评论(0) 推荐(0)
摘要:Creating custom validators is easy, just create a class inject AbstractControl. Here is the form we want to validate it: We put two custom validators 阅读全文
posted @ 2017-04-13 02:42 Zhentiw 阅读(375) 评论(0) 推荐(0)
摘要:One of the most important thing when building custom form component is adding accessbility support. The component should be focusable. we can achieve 阅读全文
posted @ 2017-04-12 02:41 Zhentiw 阅读(251) 评论(0) 推荐(0)
摘要:So when you need to create a ControlValueAccessor? When you want to use a custom component as form control. For example a counter component, you can c 阅读全文
posted @ 2017-04-09 03:02 Zhentiw 阅读(1420) 评论(0) 推荐(0)
摘要:Create an app with routing config: If you want to generate a new module with routing , you can also do: Define env variable: You can create a custom e 阅读全文
posted @ 2017-03-23 21:48 Zhentiw 阅读(233) 评论(0) 推荐(0)

上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 23 下一页