var myModule = angular.module(‘myModule',[]);
myModule.factory(‘serviceId',function() {
var someService;
//工厂方法体,构建someService
return someService;
});
angular.module(‘myModule',[],function($provide) {
$provide.factory(‘serviceId',function() {
var someService;
//工厂方法体,构建someService
return someService;
});
});
<!DOCTYPE HTML>
<html lang="zh-cn" ng-app="MainApp">
<head>
<meta charset="UTF-8">
<title>services</title>
</head>
<body>
<div ng-controller="MyController">
<input type="text" ng-model="msg"/>
<button ng-click="saveMsg()">save msg</button>
<ul>
<li ng-repeat="msg in msgs">{{msg}}</li>
</ul>
</div>
<script src="../angular-1.0.1.js" type="text/javascript"></script>
<script type="text/javascript">
var app = angular.module("MainApp",[],function($provide) {
$provide.factory("notify",["$window","$timeout",function(win,timeout) {
var msgs = [];
return function(msg) {
msgs.push(msg);
if(msgs.length==3) {
timeout(function() {
win.alert(msgs.join("\n"));
msgs = [];
},10);
}
}
}])
});
app.controller("MyController",function($scope,notify) {
$scope.msgs = [];
$scope.saveMsg = function() {
this.msgs.push(this.msg);
notify(this.msg);
this.msg = "";
};
});
</script>
</body>
</html>
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有