AngularJS2 学习笔记——创建service
来源:互联网 发布:seo黑帽很花钱吗 编辑:程序博客网 时间:2024/06/16 17:47
1. 创建文件
服务的名称使用小写,格式如:
constants.service.ts
import { Injectable } from '@angular/core';@Injectable()export class ConstantsService { abcd = 'test';}
位置假设放在:
app/constants.service.ts
2. 修改app.module.ts
import { ConstantsService } from './constants.service';
providers:[ ConstantsService]
3. 使用
在要使用的地方,假设src/page/auth/login.ts
import { ConstantsService } from '../../app/constants.service';@Component({ templateUrl: 'login.html', providers:[ConstantsService]})export class LoginPage { constructor(public navCtrl: NavController,private http: Http, private constantsService: ConstantsService) { login(user_name: HTMLInputElement, password: HTMLInputElement){ console.info('constantsService',this.constantsService.abcd); }}
阅读全文
0 0
- AngularJS2 学习笔记——创建service
- AngularJS2 学习笔记——angularjs2架构
- AngularJS2 学习笔记——JavaScript
- AngularJS2 学习笔记——TypeScript
- AngularJS2 学习笔记——Async Data Binding
- AngularJS2 学习笔记(一)
- Android Service学习笔记--创建Service
- AngularJS2 笔记
- AngularJs2-使用WebStorm创建AngularJs2项目
- AngularJs2-使用WebStorm创建AngularJs2项目
- angularjs2 学习笔记(一) 开发环境搭建 (vs2013)
- 学习笔记——Web Service
- android学习笔记四——Service
- android学习笔记2——Service
- Android学习笔记——Service
- angularjs2学习教程
- angularjs2 官方学习方式
- 为什么要学习angularjs2
- 随便写写
- MongoDB 连接池
- C#Monitor模似 Barrier
- win7/win8右键菜单添加程序
- echarts入门小案例
- AngularJS2 学习笔记——创建service
- 【Linux】几种进程间通信方式的清晰比较
- 1056: 背包2(填满型01背包)
- 欢迎使用CSDN-markdown编辑器
- SVN包含非法文件系统格式选项/包含非法文件系统格式选项
- C语言运算符优先级
- for循环实现1-10的相加
- Codeforces Round #441
- Printf函数基本概念