service 定义服务
来源:互联网 发布:java公司招聘 编辑:程序博客网 时间:2024/06/06 03:27
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script src="libs/angular.min.js"></script>
<script>
angular.module("myApp",[])
.service("gaoyn_greeter",function(){ //使用service创建一个服务
this.sayHello=function(){
alert("你好factory");
}
this.saybye=function(){
alert("再见");
}
//可以不用return 对象出去,直接使用Service对象--->自动create一个对象出来
})
//使用 angular.module("myApp",[]).controller
.controller("democ",["$scope","gaoyn_greeter",function($scope,gaoyn_greeter){
$scope.hi=function(){
gaoyn_greeter.sayHello();
}
}])
.controller("demoB",function($scope,gaoyn_greeter){
$scope.hello=function(){
gaoyn_greeter.saybye();
}
})
;
</script>
</head>
<body ng-app="myApp" ng-controller="democ">
<button ng-click="hi()">问好</button>
<button ng-controller="demoB" ng-click="hello()">再见</button>
</body>
</html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script src="libs/angular.min.js"></script>
<script>
angular.module("myApp",[])
.service("gaoyn_greeter",function(){ //使用service创建一个服务
this.sayHello=function(){
alert("你好factory");
}
this.saybye=function(){
alert("再见");
}
//可以不用return 对象出去,直接使用Service对象--->自动create一个对象出来
})
//使用 angular.module("myApp",[]).controller
.controller("democ",["$scope","gaoyn_greeter",function($scope,gaoyn_greeter){
$scope.hi=function(){
gaoyn_greeter.sayHello();
}
}])
.controller("demoB",function($scope,gaoyn_greeter){
$scope.hello=function(){
gaoyn_greeter.saybye();
}
})
;
</script>
</head>
<body ng-app="myApp" ng-controller="democ">
<button ng-click="hi()">问好</button>
<button ng-controller="demoB" ng-click="hello()">再见</button>
</body>
</html>
阅读全文
0 0
- service 定义服务
- google protobuf 定义服务(service)
- 架构Web Service:交互界面,Web服务定义的核心
- 关于Service Identification,SOA服务划分和定义
- 关于Service Identification,SOA服务划分和定义--其他
- 关于Service Identification,SOA服务划分和定义--1. 服务的分层
- 关于Service Identification,SOA服务划分和定义--2. 服务封装
- 关于Service Identification,SOA服务划分和定义--3. 服务特性
- 关于Service Identification,SOA服务划分和定义--1. 服务的分层
- 服务 | Service
- Service服务
- 服务-service
- 服务 service
- Service 服务
- Service服务
- Service 服务
- 服务(Service)
- Service服务
- http报错之return error code:401 unauthorized
- 特殊权限
- 2017年11月14日作业
- 手机号3-4-4 & 滚动函数
- 删除作业计划出错(DELETE语句与 REFERENCE约束"FK_subplan_job_id"冲突
- service 定义服务
- 做前端好还是Java好?看这三方面
- vsphere将虚拟机转换成模板需要注意的事项
- GreenDao的简单实用增删改查
- Android GreenDao的使用
- Linux下的I2S驱动
- STL常用算法: remove,remove_if,remove_copy,remove_copy_if,remove系列算法和partition的区别...
- warning LNK4006 这个烂问题终于搞掉了!
- openstack【Kilo】入门 【准备篇】三:mysql(MariaDB)安装【控制节点】