angular中的service
一些公共的方法放进service中方便各组件的调用
在要用的地方引入,并配置。配置:providers:[xxx]
不仅要在app.module中引入并配置,还需在引用的地方,并声明。声明:constructor(public xxx:xxxx){
let s = this.xxx.xxx();
}
含参的方法推荐这样写:xxx(xxx:string)
input框绑定改变事件(change)="xxxx()"
服务和服务之间可以相互调用
一些公共的方法放进service中方便各组件的调用
在要用的地方引入,并配置。配置:providers:[xxx]
不仅要在app.module中引入并配置,还需在引用的地方,并声明。声明:constructor(public xxx:xxxx){
let s = this.xxx.xxx();
}
含参的方法推荐这样写:xxx(xxx:string)
input框绑定改变事件(change)="xxxx()"
服务和服务之间可以相互调用