
Angualr2
文章平均质量分 50
zfireear
这个作者很懒,什么都没留下…
展开
-
Angular2(三)--依赖注入
provider提供具体运行时的依赖值版本使用service的Injector步骤: 1.新建一个service文件用来关联数据,通过@Injectable()注释该类成为一个Injector@Injectable()export class HeroService {getHeroes() { return HEROES; }}2.在component或module中配置provider来原创 2016-12-04 17:15:28 · 638 阅读 · 0 评论 -
Angular2(二)--属性绑定
*ngFor用来显示数组[(ngModel)]=“”用来显示双向绑定数据,{{}}用来显示单项绑定数据,为了使用双向绑定的form inputs,我们需要导入FormsModule模块,来导入包含ngModel的表单包angular绑定事件从$event中获取用户的输入,$event.target给我们一个HTMLInputElement,有一个value属性包含用户的输入数据 template原创 2016-12-04 17:12:25 · 6095 阅读 · 0 评论 -
Angular2(八)--module化(核心模块与共享模块)
Ahead-Of-time (AoT) 在main.ts可以设置AppModuleNgFactory(The app module factory produced by the static offline compiler)(main.ts)// The app module factory produced by the static offline compilerimport {原创 2016-12-04 17:32:49 · 5214 阅读 · 0 评论 -
Angular2(七)--Hierarchical dependence injection
export class EditItem<T> { editing: boolean; constructor (public item: T) {}}define an API to set a value of any type which can be altered, retrieved or set back to its initial value:https://angul原创 2016-12-04 17:28:35 · 764 阅读 · 0 评论 -
Angular2(六)--单一实例(singleton)示例
to have only one singleton in the entire application, disregarding if our modules are being loaded at bootstrap or lazy loaded单一实例:import { NgModule, ModuleWithProviders } from '@angular/core';/* ...原创 2016-12-04 17:27:37 · 1443 阅读 · 0 评论 -
Angular2(五)--router
使用angular声明周期方法,避免在constructor进行太多的工作,只需在constructor中创建和声明变量即可在ngModel的import中导入我们的router,RouterModule.forRoot() 路径可以是相对和绝对路径,“:id”这样的表示代表route参数id。data属性是与指定router关联的参数数据,对活动的router可见,空路径是默认路径,router原创 2016-12-04 17:24:58 · 3385 阅读 · 0 评论 -
Angular2(四)--promise
angular生命周期方法: 每个方法名称是在该接口名加前缀ng 使用angular生命周期需要实现相应的接口,才能使用其生命周期方法Promise异步技术使用then()方法注册,异常处理使用catch()方法 创建一个Promise对象:const p = new Promise( function (resolve, reject) { // (A) ···原创 2016-12-04 17:18:26 · 7786 阅读 · 2 评论 -
Angular2(九)--http
Angular http.get returns an RxJS Observable The AngularObservable is a bare-bones implementation. In the promise’s then callback we call the json method of the HTTP Response to extract the data原创 2016-12-04 17:38:17 · 545 阅读 · 0 评论 -
Rxjs基础
Observable:对可调用的将来value或event集合的做法 Observer:是一个回调函数集合,知道怎么监听来自Observable发送的值 Subscription:代表一个Observable的执行,最基本用涂是取消执行 Subject:事件发出者,可以传递一个value或event到observer Observables are lazy Push collections原创 2016-12-04 17:40:32 · 735 阅读 · 0 评论