<!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. atan 和 atan2

     转自http://blog.csdn.net/chinabinlang/article/details/6802686 atan函数与atan2函数的一点区别 . atan 和 atan2 都是求反 ...

  2. 适配器模式 & 装饰器模式

    一.适配器模式:简单来讲,就是为了方便使用,完成从 一个接口 到 另一个接口 的 转换,这个负责转换的就是 适配器例如:Reader ——> InputStreamReader 通过类内部组合 ...

  3. 乌班图 root权限获取

    点击左侧终端标 2 出现命令提示符 3 首先输入:sudo passwd root(设置root密码) 4 输入当前系统的账户密码(账户:admin-pc的密码) 5 输入新的root密码,确认新密码 ...

  4. python 错误 error: invalid command 'egg_info'

    Processing /bs4-0.0.1/setuptools-38.4.0/numpy-1.14.0    Complete output from command python setup.py ...

  5. 【linux高级程序设计】(第十五章)UDP网络编程应用 5

    域名与IP信息解析 /etc/hosts 文件中有部分IP地址与域名主机名的信息 /etc/resolv.conf 里面有DNS服务器的IP地址 struct hostent { char *h_na ...

  6. 服务注册和发现 Eureka

    1.项目结构如图 图中的pom.xml 是父级pom eureka-client  和 eureka-server 是两个 Module项目,创建项目都可以用 Spring Initializr 方式 ...

  7. AC日记——开关灯 codevs 1690

    开关灯 思路: 线段树: bool懒标记维护: 更新区间时是区间总值减去当前值: 来,上代码: #include <cstdio> #include <cstring> #in ...

  8. 【背包DP】【OpenJudge4978】宠物小精灵之收服

    宠物小精灵之收服 总时间限制: 1000ms 内存限制: 65536kB [描述] 宠物小精灵是一部讲述小智和他的搭档皮卡丘一起冒险的故事. 一天,小智和皮卡丘来到了小精灵狩猎场,里面有很多珍贵的野生 ...

  9. bean实例化--工厂方法

    1,编写bean package com.songyan.demo1; /** * 要创建的对象类 * @author sy * */ public class User { private Stri ...

  10. Android Developer -- Bluetooth篇 开发实例之一 扫描设备

    第一步:声明Bluetooth Permissions <!-- 设置蓝牙访问权限 --> <uses-permission android:name="android.p ...