<!DOCTYPE HTML>
<html ng-app="myApp">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<script src="angular.min.js"></script>
<script> var m1 = angular.module('myApp',[]); m1.provider('myRandom',function(){
return{
bolInt:false,
int : function(argBol){
if(argBol){
this.bolInt = true;
}else{
this.bolInt = false;
}
},
$get:function(){
var This = this;
return function(num1,num2){
return This.bolInt?Math.round(Math.random()*(num2 - num1)) + num1: Math.random()*(num2 - num1) + num1;
}
}
} })
m1.config(['myRandomProvider',function(myRandomProvider){
myRandomProvider.int(true);
}])
m1.controller('Aaa',['$scope','myRandom',function($scope,myRandom){
console.log(myRandom(-3,6));
}]) </script>
</head> <body>
<div ng-controller="Aaa"> </div>
</body>
</html>

Angular 学习笔记——$provider的更多相关文章

  1. angular 学习笔记

    每天进步一点点,学习笔记 笔记来自  angular权威指南 如果想要屏蔽浏览器对表单的默认验证行为,可以在表单元素上添加 novalidate 标记. 而按钮标签则完全忽略 hr e f 属性,并不 ...

  2. angular学习笔记

    1.forEach      arr:参数是key,index json:与jquery相反,参数是value,key2.str-->json    JSON.parse()       ang ...

  3. angular学习笔记(3)

    一.angular的核心 1.组件 2.指令 3.服务 4.依赖注入

  4. angular学习笔记(2)

    1.angular可观察对象 2.angular绑定方式 3.angular模板 4.angular生命周期 5.angular组件通信

  5. Angular 学习笔记——$http

    <!DOCTYPE HTML> <html ng-app="myApp"> <head> <meta http-equiv="C ...

  6. Log4j简单学习笔记

    log4j结构图: 结构图展现出了log4j的主结构.logger:表示记录器,即数据来源:appender:输出源,即输出方式(如:控制台.文件...)layout:输出布局 Logger机滤器:常 ...

  7. angular学习资源

    angular学习资源   angularjs库: https://developers.google.com/speed/libraries/devguide?hl=zh-CN#angularjs ...

  8. 小波说雨燕 第三季 构建 swift UI 之 UI组件集-视图集(六)Picker View视图 学习笔记

    想对PickerView进行操作,只能在代码中操作. 下面 ,再添加三个label组件,然后将所有组件配置到代码中(看代码),然后要实现对PickerView的操作,就要实现它的DataSource协 ...

  9. DSP bootloader学习笔记1

    DSP bootloader学习笔记1 彭会锋 参考: TMS320F28xx DSP中内部Flash的应用研究 http://wenku.baidu.com/view/83e9837931b765c ...

随机推荐

  1. pagination用法

    pagination用法: 1.html  要用两层div <script src="${app }/pc/js/media/pagination.js"></s ...

  2. Velocity模版使用

    <!-- https://mvnrepository.com/artifact/org.apache.velocity/velocity --> <dependency> &l ...

  3. 解决jquery与zepto等其它库冲突兼容的问题

    解决jquery与zepto等其它库冲突兼容的问题;(function ($) {    }) (jQuery); ;(function ($) {    }) (Zepto); 在Bootstrap ...

  4. 使用 padding-bottom 设置高度基于宽度的自适应

    我们在做移动端列表,通常会做到图文列表,列表是自适应的.当列表中有图片,图片的宽度是随着列表宽的变化而变化,我们为了在图片宽度变化的时候做到图片的不变形,所有采用以下办法. 本文章只讲语法 html ...

  5. (二十五)epoll深入理解续

    转自:http://blog.csdn.net/yusiguyuan/article/details/15027821 在Linux的网络编程中,很长的时间都在使用select来做事件触发.在linu ...

  6. leetcode-Min Cost Climbing Stairs

    题目: On a staircase, the i-th step has some non-negative cost cost[i] assigned (0 indexed). Once you ...

  7. 这绝对是有史以来最详细的web前端学习路线

    定要善用开发者工具.firefox的firebug和Chrome的F12都是很好的选择,用好了这个必会发现他带给你的帮助比看一本书更多.你把firebug摸透了你还担心对DOM理解不够?考虑到未来,h ...

  8. CF988 C. Equal Sums【map+pair/hash/任选两个序列,两个序列都除去他们中的一个数,使的总和相同】

    [链接]:CF988C [题意]:在n个序列中任选两个序列,两个序列都除去他们中的一个数,使的总和相同 [分析]:map<int,pair<int,int> > mp,从0~m ...

  9. POJ 3620 Avoid The Lakes【DFS找联通块】

    Avoid The Lakes Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 6826   Accepted: 3637 D ...

  10. bzoj 5163: 第k大斜率

    5163: 第k大斜率 Time Limit: 10 Sec  Memory Limit: 512 MBSubmit: 15  Solved: 4[Submit][Status][Discuss] D ...