Tag Archives: javascript

How to get the url parameters using angular js

I know this is an old question, but it took me some time to sort this out given the sparse Angular documentation. The RouteProvider and routeParams is the way to go. The route wires up the URL to your Controller/View and the routeParams can be passed... Read More | Share it now!

AngularJS cookies

Angular-cookies Doc: https://docs.angularjs.org/api/ngCookies/service/$cookies Download angular-cookies.js: https://docs.angularjs.org/api/ngCookies https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular-cookies.js controller.js var myApp =... Read More | Share it now!

javascript获取随机颜色

http://www.cnblogs.com/rubylouvre/archive/2009/09/24/1572977.html   在制作饼图或标签云时,我们通常需要很多颜色,方法有二。一是准备一组漂亮的候选颜色,二是随机生成颜色。在数量很多或不明确时,我想后者就是唯一的出路了。谷歌了一下,整理如下,按由浅入深的顺序排列。 实现1 var... Read More | Share it now!

十个JavaScript中易犯的小错误,你中了几枪?

在今天,JavaScript已经成为了网页编辑的核心。尤其是过去的几年,互联网见证了在SPA开发、图形处理、交互等方面大量JS库的出现。 如果初次打交道,很多人会觉得js很简单。确实,对于很多有经验的工程师,或者甚至是初学者而言,实现基本的js功能几乎毫无障碍。但是JS的真实功能却比很多人想象的要更加多样、复杂。JavaScript的许多细节规定会让你的网页出现很多意想不到的bug,搞懂这些bug,对于成为一位有经验的JS开发者很重要。 常见错误一:对于this关键词的不正确引用 我曾经听一位喜剧演员说过: “我从未在这里,因为我不清楚这里是哪里,是除了那里之外的地方吗?” 这句话或多或少地暗喻了在js开发中开发者对于this关键字的使用误区。This指代的是什么?它和日常英语口语中的this是一个意思吗? 随着近些年js编程不断地复杂化,功能多样化,对于一个程序结构的内部指引、引用也逐渐变多起来 下面让我们一起来看这一段代码: Game.prototype.restart... Read More | Share it now!

什么是闭包(closures)

什么是闭包(closures): 闭包就是内部函数通过某种方式使其可见范围超出了其定义的范围,这就产生了一个在其定义范围内的闭包. 这是我理解后的一个定义,呵呵!很晦涩吧!不过没关系,可以先看看下面的讲解. 一... Read More | Share it now!

Access-Control-Allow-Origin 浏览器js跨域问题

XMLHttpRequest cannot load http://xxxx. No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘http://yyyy’ is therefore not allowed... Read More | Share it now!