<!DOCTYPE html>
<html ng-app="demo">
<head>
<link rel="stylesheet" href="style.css">
<!--
IE8 support, see AngularJS Internet Explorer Compatibility https://docs.angularjs.org/guide/ie
For Firefox 3.6, you will also need to include jQuery and ECMAScript 5 shim
-->
<!--[if lt IE 9]>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/es5-shim/2.2.0/es5-shim.js"></script>
<script>
document.createElement('ui-select');
document.createElement('ui-select-match');
document.createElement('ui-select-choices');
</script>
<![endif]-->
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular-sanitize.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.js"></script>
<!-- themes -->
<link rel="stylesheet" href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/select2/3.4.5/select2.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.8.5/css/selectize.default.css">
<!-- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.8.5/css/selectize.bootstrap2.css"> -->
<!--<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.8.5/css/selectize.bootstrap3.css">-->
<script src="script.js"></script>
</head>
<body class="ng-cloak" ng-controller="DemoCtrl as ctrl">
<div id="eleTest"></div>
</body>
</html>
// Code goes here
// Code goes here
(function() {
'use strict';
var app = angular.module('demo', []);
app.controller('DemoCtrl', function() {
var values = {
name: 'misko',
gender: 'male'
};
var log = [];
angular.forEach(values, function(value, key) {
this.push(key + ':' + value);
}, log);
console.log(log); // ["name:misko", "gender:male"]
angular.forEach(log, function(value, key) {
console.log(value + "," + key);
});
// name:misko,0
// gender:male,1
angular.forEach(log, function(value, key, obj) {
// obj[key] 和 value
console.log(value + "," + key + "," + obj[key]);
});
// name:misko,0,name:misko
// gender:male,1,gender:male
console.log('------------------------------------------------------');
var a;
console.log("a:%s isUndefined:%s", a, angular.isUndefined(a)); // true
a = "vala";
console.log("a:%s isUndefined:%s", a, angular.isUndefined(a)); // false
a = null;
console.log("a:%s isUndefined:%s", a, angular.isUndefined(a)); // false
a = '';
console.log("a:%s isUndefined:%s", a, angular.isUndefined(a)); // false
a = "";
console.log("a:%s isUndefined:%s", a, angular.isUndefined(a)); // false
a = {};
console.log("a:%s isUndefined:%s", a, angular.isUndefined(a)); // false
console.log("a:%s isUndefined:%s", a, angular.isUndefined(a.name)); // true
a = [];
console.log("a:%s isUndefined:%s", a, angular.isUndefined(a)); // false
a = undefined;
console.log("a:%s isUndefined:%s", a, angular.isUndefined(a)); // true
console.log('------------------------------------------------------');
var b;
console.log("b:%s isDefined:%s", b, angular.isDefined(b)); // false
b = "vala";
console.log("b:%s isDefined:%s", b, angular.isDefined(b)); // true
b = null;
console.log("b:%s isDefined:%s", b, angular.isDefined(b)); // true
b = '';
console.log("b:%s isDefined:%s", b, angular.isDefined(b)); // true
b = "";
console.log("b:%s isDefined:%s", b, angular.isDefined(b)); // true
b = {};
console.log("b:%s isDefined:%s", b, angular.isDefined(b)); // true
console.log("b:%s isDefined:%s", b, angular.isDefined(b.name)); // false
b = [];
console.log("b:%s isDefined:%s", b, angular.isDefined(b)); // true
b = undefined;
console.log("b:%s isDefined:%s", b, angular.isDefined(b)); // false
console.log('------------------------------------------------------');
// angular.isObject
var c;
console.log("c:%s isObject:%s", c, angular.isObject(c)); // false
c = "vala";
console.log("c:%s isObject:%s", c, angular.isObject(c)); // false
c = null;
console.log("c:%s isObject:%s", c, angular.isObject(c)); // false
c = '';
console.log("c:%s isObject:%s", c, angular.isObject(c)); // false
c = "";
console.log("c:%s isObject:%s", c, angular.isObject(c)); // false
c = {};
console.log("c:%s isObject:%s", c, angular.isObject(c)); // true
c = [];
console.log("c:%s isObject:%s", c, angular.isObject(c)); // true
c = undefined;
console.log("c:%s isObject:%s", c, angular.isObject(c)); // false
console.log('------------------------------------------------------');
// angular.isArray
var d;
console.log("d:%s isArray:%s", d, angular.isArray(d)); // false
d = "vala";
console.log("d:%s isArray:%s", d, angular.isArray(d)); // false
d = null;
console.log("d:%s isArray:%s", d, angular.isArray(d)); // false
d = '';
console.log("d:%s isArray:%s", d, angular.isArray(d)); // false
d = "";
console.log("d:%s isArray:%s", d, angular.isArray(d)); // false
d = {};
console.log("d:%s isArray:%s", d, angular.isArray(d)); // false
d = [];
console.log("d:%s isArray:%s", d, angular.isArray(d)); // true
d = undefined;
console.log("d:%s isArray:%s", d, angular.isArray(d)); // false
console.log('------------------------------------------------------');
// angular.isDate
var e;
console.log("e:%s isDate:%s", e, angular.isDate(e)); // false
e = "2014-12-14";
console.log("e:%s isDate:%s", e, angular.isDate(e)); // false
e = new Date();
console.log("e:%s isDate:%s", e, angular.isDate(e)); // true
e = null;
console.log("e:%s isDate:%s", e, angular.isDate(e)); // false
e = '';
console.log("e:%s isDate:%s", e, angular.isDate(e)); // false
e = "";
console.log("e:%s isDate:%s", e, angular.isDate(e)); // false
e = {};
console.log("e:%s isDate:%s", e, angular.isDate(e)); // false
e = [];
console.log("e:%s isDate:%s", e, angular.isDate(e)); // false
e = undefined;
console.log("e:%s isDate:%s", e, angular.isDate(e)); // false
console.log('------------------------------------------------------');
// angular.isFunction
var f;
console.log("f:%s isFunction:%s", f, angular.isFunction(f)); // false
f = "2014-12-14";
console.log("f:%s isFunction:%s", f, angular.isFunction(f)); // false
f = function() {};
console.log("f:%s isFunction:%s", f, angular.isFunction(f)); // true
f = null;
console.log("f:%s isFunction:%s", f, angular.isFunction(f)); // false
f = '';
console.log("f:%s isFunction:%s", f, angular.isFunction(f)); // false
f = "";
console.log("f:%s isFunction:%s", f, angular.isFunction(f)); // false
f = {};
console.log("f:%s isFunction:%s", f, angular.isFunction(f)); // false
f = [];
console.log("f:%s isFunction:%s", f, angular.isFunction(f)); // false
f = undefined;
console.log("f:%s isFunction:%s", f, angular.isFunction(f)); // false
console.log('------------------------------------------------------');
// angular.isElement
var g;
console.log("g:%s isElement:%s", g, angular.isElement(g)); // false
g = "2014-12-14";
console.log("g:%s isElement:%s", g, angular.isElement(g)); // false
g = document.getElementById('eleTest'); // 原生js
console.log("g:%s isElement:%s", g, angular.isElement(g)); // true
g = angular.element(document).find('#eleTest'); // angularJS 内置jQuery
console.log("g:%s isElement:%s", g, angular.isElement(g)); // true
g = $('#eleTest'); // jQuery 的方式
console.log("g:%s isElement:%s", g, angular.isElement(g)); // true
g = null;
console.log("g:%s isElement:%s", g, angular.isElement(g)); // false
g = '';
console.log("g:%s isElement:%s", g, angular.isElement(g)); // false
g = "";
console.log("g:%s isElement:%s", g, angular.isElement(g)); // false
g = {};
console.log("g:%s isElement:%s", g, angular.isElement(g)); // false
g = [];
console.log("g:%s isElement:%s", g, angular.isElement(g)); // false
g = undefined;
console.log("g:%s isElement:%s", g, angular.isElement(g)); // false
console.log('------------------------------------------------------');
// angular.isString
var h;
console.log("h:%s isString:%s", h, angular.isString(h)); // false
h = "2014-12-14";
console.log("h:%s isString:%s", h, angular.isString(h)); // true
h = null;
console.log("h:%s isString:%s", h, angular.isString(h)); // false
h = '';
console.log("h:%s isString:%s", h, angular.isString(h)); // true
h = "";
console.log("h:%s isString:%s", h, angular.isString(h)); // true
h = {};
console.log("h:%s isString:%s", h, angular.isString(h)); // false
h = [];
console.log("h:%s isString:%s", h, angular.isString(h)); // false
h = undefined;
console.log("h:%s isString:%s", h, angular.isString(h)); // false
console.log('------------------------------------------------------');
// angular.isNumber
var j;
console.log("j:%s isNumber:%s", j, angular.isNumber(j)); // false
j = "2014-12-14";
console.log("j:%s isNumber:%s", j, angular.isNumber(j)); // false
j = null;
console.log("j:%s isNumber:%s", j, angular.isNumber(j)); // false
j = '';
console.log("j:%s isNumber:%s", j, angular.isNumber(j)); // false
j = "";
console.log("j:%s isNumber:%s", j, angular.isNumber(j)); // false
j = {};
console.log("j:%s isNumber:%s", j, angular.isNumber(j)); // false
j = [];
console.log("j:%s isNumber:%s", j, angular.isNumber(j)); // false
j = undefined;
console.log("j:%s isNumber:%s", j, angular.isNumber(j)); // false
j = 12;
console.log("j:%s isNumber:%s", j, angular.isNumber(j)); // true
j = NaN;
console.log("j:%s isNumber:%s", j, angular.isNumber(j)); // true
j = +Infinity;
console.log("j:%s isNumber:%s", j, angular.isNumber(j)); // true
j = -Infinity;
console.log("j:%s isNumber:%s", j, angular.isNumber(j)); // true
console.log("NaN isNaN:%s", isNaN(NaN)); // true
console.log("NaN isFinite:%s", isFinite(NaN)); // false
console.log("+Infinity isFinite:%s", isFinite(+Infinity)); // false
console.log("-Infinity isFinite:%s", isFinite(-Infinity)); // false
});
})();
/* Styles go here */
console.log('------------------------------------------------------');
// angular.equals
var h;
console.log("h:%s equals:%s", h, angular.equals(h, h)); // true
h = "2014-12-14";
console.log("h:%s equals:%s", h, angular.equals(h, h)); // true
h = new Date();
console.log("h:%s equals:%s", h, angular.equals(h, h)); // true
h = function() {};
var h2 = function() {
var abc = 'abcd';
};
console.log("h:%s equals:%s", h, angular.equals(h, h)); // true
console.log("h:%s equals:%s", h2, angular.equals(h, h2)); // false
h = null;
console.log("h:%s equals:%s", h, angular.equals(h, h)); // true
h = '';
console.log("h:%s equals:%s", h, angular.equals(h, h)); // true
h = "";
console.log("h:%s equals:%s", h, angular.equals(h, h)); // true
h = {};
console.log("h:%s equals:%s", h, angular.equals(h, h)); // true
console.log("h:%s equals:%s", h, angular.equals(h, {
'name': 'joe'
})); // false
h = [];
console.log("h:%s equals:%s", h, angular.equals(h, h)); // true
h = undefined;
console.log("h:%s equals:%s", h, angular.equals(h, h)); // true
console.log('------------------------------------------------------');
// angular.bind
var self = {
name: 'boyi'
};
//示例1--带参数
var fb = angular.bind(self, //绑定对象,作为函数的上下文
//被绑定的函数
function(age) {
console.log(this.name + ' is ' + age + ' !')
},
//绑定的参数,可省略
'15'
);
fb(); //调用绑定之后的function
//示例2--不带参数
var mb = angular.bind(self, //绑定对象,作为函数的上下文
//被绑定的函数
function(age) {
console.log(this.name + ' is ' + age + ' !')
}
//省略参数
);
mb(3); //调用传参的函数
console.log('------------------------------------------------------');
// angular.toJson
var j;
console.log("h:%s toJson:%s", h, angular.toJson(h, true)); // undefined
j = "2014-12-14";
console.log("j:%s toJson:%s", j, angular.toJson(j, true)); // "2014-12-14"
j = new Date();
console.log("j:%s toJson:%s", j, angular.toJson(j, true)); // "2019-05-30T02:11:19.967Z"
j = function() {};
console.log("j:%s toJson:%s", j, angular.toJson(j, true)); // undefined
j = null;
console.log("j:%s toJson:%s", j, angular.toJson(j, true)); // null
j = '';
console.log("j:%s toJson:%s", j, angular.toJson(j, true)); // ""
j = "";
console.log("j:%s toJson:%s", j, angular.toJson(j, true)); // ""
j = {};
console.log("j:%s toJson:%s", j, angular.toJson(j, true)); // {}
j = [];
console.log("j:%s toJson:%s", j, angular.toJson(j, true)); // []
j = undefined;
console.log("j:%s toJson:%s", j, angular.toJson(j, true)); // undefined
j = {name:'abc'};
console.log("j:%s toJson(j, true): \n%s", j, angular.toJson(j, true));
console.log("j:%s toJson(j, false): \n%s", j, angular.toJson(j, false));
console.log("j:%s toJson(j): \n%s", j, angular.toJson(j));
console.log("j:%s toJson(j, 4): \n%s", j, angular.toJson(j, 4));
console.log('------------------------------------------------------');
// angular.fromJson
var q;
console.log("q:%s fromJson:%s", q, angular.fromJson(q)); // undefined
q = {date: "2014-12-14"};
console.log("q:%s fromJson:%s", q, angular.fromJson(q)); // [object Object]
q = new Date();
console.log("q:%s fromJson:%s", q, angular.fromJson(q)); // Thu May 30 2019 10:41:36 GMT+0800 (中国标准时间)
q = function() {};
console.log("q:%s fromJson:%s", q, angular.fromJson(q)); // function() {}
q = null;
console.log("q:%s fromJson:%s", q, angular.fromJson(q)); // null
q = {};
console.log("q:%s fromJson:%s", q, angular.fromJson(q)); // [object Object]
q = [];
console.log("q:%s fromJson:%s", q, angular.fromJson(q)); //
q = undefined;
console.log("q:%s fromJson:%s", q, angular.fromJson(q)); // undefined