2014 年文章归档
共 5 篇文章
Passing data into a directive
<div my-directive my-url="http://google.com" my-link-text="Click me to go to Google"></div> angular.module('myApp', []) .directive('myDirective', function() { return { restrict: 'A', replace: true, scope: { // isolate scope myUrl: '@', // binding strategy myLinkText: '@' // binding strategy }, temp…
2014-08-09 20:45 · Angularjs
word-break
-ms-word-break: break-all; word-break: break-all; /* Non standard for webkit */ word-break: break-word; -webkit-hyphens: auto; -moz-hyphens: auto; -ms-hyphens: auto; hyphens: auto;
2014-05-29 11:24 · css3
JS数组的去重与降维
去重: 创建一个空数组和一个空对象,在for循环中,每次取出一个元素,检测是否已经是对象的key,如果不存在就加入到新建的数组中。 降维: 由于不能给this赋值,所以先将数组赋值给that。在for循环中,每次取出一个元素,检测是否是数组。如果是,把数组拆分成3个部分:当前元素之前所有元素组成的数组、当前元素(也是数组)、当前元素之后的所有元素组成的数组。用concat将这三个数组重新合并为一个新数组,由于for循环会index+1,把当前的index-1,保持index不变,重新做一次检测。因为当前元素这个数组里面的第一个元素也可能还是一个数组。 // 去重 Array.prototyp…
2014-04-10 01:12 · JavaScript
两种交换排序:冒泡排序与快速排序
冒泡排序 ***基本思想:***把数组垂直排列,把各项的值当作气泡的重量。根据轻气泡不能在重气泡之下的原则,从下往上扫描数组:凡扫描到违反本原则的轻气泡,就使其向上“漂浮”。如此反复进行,直到最后两个气泡都是轻者在上,重者在下为止。 function bubbleSort(arr){ var len = arr.length, i, j, temp; var exchange = false; for(i = 0; i < len; i++){ exchange = false; for(j = len-1; j > i; j--){ if(j && (arr[j] < arr[j-1]))…
2014-04-02 23:15 · JavaScript
计算CSS选择器的特性(选择器优先级)
下面是W3官方的描述 A selector's specificity is calculated as follows: count the number of ID selectors in the selector (= a) count the number of class selectors, attributes selectors, and pseudo-classes in the selector (= b) count the number of type selectors and pseudo-elements in the selector (= c) ignor…
2014-04-02 16:04 · css3