原文:https://github.com/grevory/angular-local-storage#api-documentation

Get Started

(1)Bower: $ bower install angular-local-storage --save

npm: $ npm install angular-local-storage

(2) Include angular-local-storage.js (or angular-local-storage.min.js) from the dist directory in your index.html, after including Angular itself.

(3) Add 'LocalStorageModule' to your main module's list of dependencies.

When you're done, your setup should look similar to the following:

  1. <!doctype html>
  2. <html ng-app="myApp">
  3. <head>
  4. </head>
  5. <body><script src="//ajax.googleapis.com/ajax/libs/angularjs/1.1.5/angular.min.js"></script>
  6. <script src="bower_components/js/angular-local-storage.min.js"></script>
  7. <script>
  8. var myApp = angular.module('myApp', ['LocalStorageModule']);
  9. </script>
  10. </body>
  11. </html>

Configuration

setPrefix

You could set a prefix to avoid overwriting any local storage variables from the rest of your app
Default prefix: ls.<your-key>

  1. myApp.config(function (localStorageServiceProvider) {
  2. localStorageServiceProvider
  3. .setPrefix('yourAppName');
  4. });

setStorageType

You could change web storage type to localStorage or sessionStorage
Default storage: localStorage

  1. myApp.config(function (localStorageServiceProvider) {
  2. localStorageServiceProvider
  3. .setStorageType('sessionStorage');
  4. });

setDefaultToCookie

If localStorage is not supported, the library will default to cookies instead. This behavior can be disabled.
Default: true

  1. myApp.config(function (localStorageServiceProvider) {
  2. localStorageServiceProvider
  3. .setDefaultToCookie(false);
  4. });

setStorageCookie

Set cookie options (usually in case of fallback)
expiry: number of days before cookies expire (0 = session cookie). default: 30
path: the web path the cookie represents. default: '/'
secure: whether to store cookies as secure. default: false

  1. myApp.config(function (localStorageServiceProvider) {
  2. localStorageServiceProvider
  3. .setStorageCookie(45, '<path>', false);
  4. });

setStorageCookieDomain

Set the cookie domain, since this runs inside a the config() block, only providers and constants can be injected. As a result,$location service can't be used here, use a hardcoded string or window.location.
No default value

  1. myApp.config(function (localStorageServiceProvider) {
  2. localStorageServiceProvider
  3. .setStorageCookieDomain('<domain>');
  4. });

For local testing (when you are testing on localhost) set the domain to an empty string ''. Setting the domain to 'localhost' will not work on all browsers (eg. Chrome) since some browsers only allow you to set domain cookies for registry controlled domains, i.e. something ending in .com or so, but not IPs or intranet hostnames like localhost.

setNotify

Configure whether events should be broadcasted on $rootScope for each of the following actions:
setItem , default: true, event "LocalStorageModule.notification.setitem"
removeItem , default: false, event "LocalStorageModule.notification.removeitem"

  1. myApp.config(function (localStorageServiceProvider) {
  2. localStorageServiceProvider
  3. .setNotify(true, true);
  4. });

Configuration Example

Using all together

  1. myApp.config(function (localStorageServiceProvider) {
  2. localStorageServiceProvider
  3. .setPrefix('myApp')
  4. .setStorageType('sessionStorage')
  5. .setNotify(true, true)
  6. });

API Documentation

isSupported

Checks if the browser support the current storage type(e.g: localStoragesessionStorage). Returns: Boolean

  1. myApp.controller('MainCtrl', function($scope, localStorageService) {
  2. //...
  3. if(localStorageService.isSupported) {
  4. //...
  5. }
  6. //...
  7. });

getStorageType

Returns: String

  1. myApp.controller('MainCtrl', function($scope, localStorageService) {
  2. //...
  3. var storageType = localStorageService.getStorageType(); //e.g localStorage
  4. //...
  5. });

You can also dynamically change storage type by passing the storage type as the last parameter for any of the API calls. For example: localStorageService.set(key, val, "sessionStorage");

set

Directly adds a value to local storage.
If local storage is not supported, use cookies instead.
Returns: Boolean

  1. myApp.controller('MainCtrl', function($scope, localStorageService) {
  2. function submit(key, val) {
  3. return localStorageService.set(key, val);
  4. }
  5. });

get

Directly get a value from local storage.
If local storage is not supported, use cookies instead.
Returns: value from local storage

  1. myApp.controller('MainCtrl', function($scope, localStorageService) {
  2. //...
  3. function getItem(key) {
  4. return localStorageService.get(key);
  5. }
  6. //...
  7. });

keys

Return array of keys for local storage, ignore keys that not owned.
Returns: value from local storage

  1. myApp.controller('MainCtrl', function($scope, localStorageService) {
  2. //...
  3. var lsKeys = localStorageService.keys();
  4. //...
  5. });

remove

Remove an item(s) from local storage by key.
If local storage is not supported, use cookies instead.
Returns: Boolean

  1. myApp.controller('MainCtrl', function($scope, localStorageService) {
  2. //...
  3. function removeItem(key) {
  4. return localStorageService.remove(key);
  5. }
  6. //...
  7. function removeItems(key1, key2, key3) {
  8. return localStorageService.remove(key1, key2, key3);
  9. }
  10. });

clearAll

Remove all data for this app from local storage.
If local storage is not supported, use cookies instead.
Note: Optionally takes a regular expression string and removes matching.
Returns: Boolean

  1. myApp.controller('MainCtrl', function($scope, localStorageService) {
  2. //...
  3. function clearNumbers(key) {
  4. return localStorageService.clearAll(/^\d+$/);
  5. }
  6. //...
  7. function clearAll() {
  8. return localStorageService.clearAll();
  9. }
  10. });

bind

Bind $scope key to localStorageService. Usage: localStorageService.bind(scope, property, value[optional], key[optional]) key: The corresponding key used in local storage Returns: deregistration function for this listener.

  1. myApp.controller('MainCtrl', function($scope, localStorageService) {
  2. //...
  3. localStorageService.set('property', 'oldValue');
  4. $scope.unbind = localStorageService.bind($scope, 'property');
  5.  
  6. //Test Changes
  7. $scope.update = function(val) {
  8. $scope.property = val;
  9. $timeout(function() {
  10. alert("localStorage value: " + localStorageService.get('property'));
  11. });
  12. }
  13. //...
  14. });
  1. <div ng-controller="MainCtrl">
  2. <p>{{property}}</p>
  3. <input type="text" ng-model="lsValue"/>
  4. <button ng-click="update(lsValue)">update</button>
  5. <button ng-click="unbind()">unbind</button>
  6. </div>

deriveKey

Return the derive key Returns String

  1. myApp.controller('MainCtrl', function($scope, localStorageService) {
  2. //...
  3. localStorageService.set('property', 'oldValue');
  4. //Test Result
  5. console.log(localStorageService.deriveKey('property')); // ls.property
  6. //...
  7. });

length

Return localStorageService.length, ignore keys that not owned. Returns Number

  1. myApp.controller('MainCtrl', function($scope, localStorageService) {
  2. //...
  3. var lsLength = localStorageService.length(); // e.g: 7
  4. //...
  5. });

Cookie

Deal with browser's cookies directly.

cookie.isSupported

Checks if cookies are enabled in the browser. Returns: Boolean

  1. myApp.controller('MainCtrl', function($scope, localStorageService) {
  2. //...
  3. if(localStorageService.cookie.isSupported) {
  4. //...
  5. }
  6. //...
  7. });

cookie.set

Directly adds a value to cookies.
Note: Typically used as a fallback if local storage is not supported.
Returns: Boolean

  1. myApp.controller('MainCtrl', function($scope, localStorageService) {
  2. //...
  3. function submit(key, val) {
  4. return localStorageService.cookie.set(key, val);
  5. }
  6. //...
  7. });

Cookie Expiry Pass a third argument to specify number of days to expiry

  1. localStorageService.cookie.set(key,val,10)

sets a cookie that expires in 10 days. Secure Cookie Pass a fourth argument to set the cookie as secure W3C

  1. localStorageService.cookie.set(key,val,null,false)

sets a cookie that is secure.

cookie.get

Directly get a value from a cookie.
Returns: value from local storage

  1. myApp.controller('MainCtrl', function($scope, localStorageService) {
  2. //...
  3. function getItem(key) {
  4. return localStorageService.cookie.get(key);
  5. }
  6. //...
  7. });

cookie.remove

Remove directly value from a cookie.
Returns: Boolean

  1. myApp.controller('MainCtrl', function($scope, localStorageService) {
  2. //...
  3. function removeItem(key) {
  4. return localStorageService.cookie.remove(key);
  5. }
  6. //...
  7. });

cookie.clearAll

Remove all data for this app from cookie.
Returns: Boolean

  1. myApp.controller('MainCtrl', function($scope, localStorageService) {
  2. //...
  3. function clearAll() {
  4. return localStorageService.cookie.clearAll();
  5. }
  6. });

Check out the full demo at http://gregpike.net/demos/angular-local-storage/demo.html

Development:

  • Don't forget about tests.
  • If you're planning to add some feature please create an issue before.

Clone the project:

  1. $ git clone https://github.com/<your-repo>/angular-local-storage.git
  2. $ npm install
  3. $ bower install

Run the tests:

  1. $ grunt test

Deploy:
Run the build task, update version before(bower,package)

  1. $ npm version patch|minor|major
  2. $ grunt dist
  3. $ git commit [message]
  4. $ git push origin master --tags

Get Started

(1) You can install angular-local-storage using 3 different ways:
Git: clone & build this repository
Bower:

  1. $ bower install angular-local-storage --save

npm:

  1. $ npm install angular-local-storage

(2) Include angular-local-storage.js (or angular-local-storage.min.js) from the dist directory in your index.html, after including Angular itself.

(3) Add 'LocalStorageModule' to your main module's list of dependencies.

When you're done, your setup should look similar to the following:

  1. <!doctype html>
  2. <html ng-app="myApp">
  3. <head>
  4.  
  5. </head>
  6. <body>
  7. ...
  8. <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.1.5/angular.min.js"></script>
  9. <script src="bower_components/js/angular-local-storage.min.js"></script>
  10. ...
  11. <script>
  12. var myApp = angular.module('myApp', ['LocalStorageModule']);
  13.  
  14. </script>
  15. ...
  16. </body>
  17. </html>

Configuration

setPrefix

You could set a prefix to avoid overwriting any local storage variables from the rest of your app
Default prefix: ls.<your-key>

  1. myApp.config(function (localStorageServiceProvider) {
  2. localStorageServiceProvider
  3. .setPrefix('yourAppName');
  4. });

setStorageType

You could change web storage type to localStorage or sessionStorage
Default storage: localStorage

  1. myApp.config(function (localStorageServiceProvider) {
  2. localStorageServiceProvider
  3. .setStorageType('sessionStorage');
  4. });

setDefaultToCookie

If localStorage is not supported, the library will default to cookies instead. This behavior can be disabled.
Default: true

  1. myApp.config(function (localStorageServiceProvider) {
  2. localStorageServiceProvider
  3. .setDefaultToCookie(false);
  4. });

setStorageCookie

Set cookie options (usually in case of fallback)
expiry: number of days before cookies expire (0 = session cookie). default: 30
path: the web path the cookie represents. default: '/'
secure: whether to store cookies as secure. default: false

  1. myApp.config(function (localStorageServiceProvider) {
  2. localStorageServiceProvider
  3. .setStorageCookie(45, '<path>', false);
  4. });

setStorageCookieDomain

Set the cookie domain, since this runs inside a the config() block, only providers and constants can be injected. As a result,$location service can't be used here, use a hardcoded string or window.location.
No default value

  1. myApp.config(function (localStorageServiceProvider) {
  2. localStorageServiceProvider
  3. .setStorageCookieDomain('<domain>');
  4. });

For local testing (when you are testing on localhost) set the domain to an empty string ''. Setting the domain to 'localhost' will not work on all browsers (eg. Chrome) since some browsers only allow you to set domain cookies for registry controlled domains, i.e. something ending in .com or so, but not IPs or intranet hostnames like localhost.

setNotify

Configure whether events should be broadcasted on $rootScope for each of the following actions:
setItem , default: true, event "LocalStorageModule.notification.setitem"
removeItem , default: false, event "LocalStorageModule.notification.removeitem"

  1. myApp.config(function (localStorageServiceProvider) {
  2. localStorageServiceProvider
  3. .setNotify(true, true);
  4. });

Configuration Example

Using all together

  1. myApp.config(function (localStorageServiceProvider) {
  2. localStorageServiceProvider
  3. .setPrefix('myApp')
  4. .setStorageType('sessionStorage')
  5. .setNotify(true, true)
  6. });

API Documentation

isSupported

Checks if the browser support the current storage type(e.g: localStoragesessionStorage). Returns: Boolean

  1. myApp.controller('MainCtrl', function($scope, localStorageService) {
  2. //...
  3. if(localStorageService.isSupported) {
  4. //...
  5. }
  6. //...
  7. });

getStorageType

Returns: String

  1. myApp.controller('MainCtrl', function($scope, localStorageService) {
  2. //...
  3. var storageType = localStorageService.getStorageType(); //e.g localStorage
  4. //...
  5. });

You can also dynamically change storage type by passing the storage type as the last parameter for any of the API calls. For example: localStorageService.set(key, val, "sessionStorage");

set

Directly adds a value to local storage.
If local storage is not supported, use cookies instead.
Returns: Boolean

  1. myApp.controller('MainCtrl', function($scope, localStorageService) {
  2. //...
  3. function submit(key, val) {
  4. return localStorageService.set(key, val);
  5. }
  6. //...
  7. });

get

Directly get a value from local storage.
If local storage is not supported, use cookies instead.
Returns: value from local storage

  1. myApp.controller('MainCtrl', function($scope, localStorageService) {
  2. //...
  3. function getItem(key) {
  4. return localStorageService.get(key);
  5. }
  6. //...
  7. });

keys

Return array of keys for local storage, ignore keys that not owned.
Returns: value from local storage

  1. myApp.controller('MainCtrl', function($scope, localStorageService) {
  2. //...
  3. var lsKeys = localStorageService.keys();
  4. //...
  5. });

remove

Remove an item(s) from local storage by key.
If local storage is not supported, use cookies instead.
Returns: Boolean

  1. myApp.controller('MainCtrl', function($scope, localStorageService) {
  2. //...
  3. function removeItem(key) {
  4. return localStorageService.remove(key);
  5. }
  6. //...
  7. function removeItems(key1, key2, key3) {
  8. return localStorageService.remove(key1, key2, key3);
  9. }
  10. });

clearAll

Remove all data for this app from local storage.
If local storage is not supported, use cookies instead.
Note: Optionally takes a regular expression string and removes matching.
Returns: Boolean

  1. myApp.controller('MainCtrl', function($scope, localStorageService) {
  2. //...
  3. function clearNumbers(key) {
  4. return localStorageService.clearAll(/^\d+$/);
  5. }
  6. //...
  7. function clearAll() {
  8. return localStorageService.clearAll();
  9. }
  10. });

bind

Bind $scope key to localStorageService. Usage: localStorageService.bind(scope, property, value[optional], key[optional]) key: The corresponding key used in local storage Returns: deregistration function for this listener.

  1. myApp.controller('MainCtrl', function($scope, localStorageService) {
  2. //...
  3. localStorageService.set('property', 'oldValue');
  4. $scope.unbind = localStorageService.bind($scope, 'property');
  5.  
  6. //Test Changes
  7. $scope.update = function(val) {
  8. $scope.property = val;
  9. $timeout(function() {
  10. alert("localStorage value: " + localStorageService.get('property'));
  11. });
  12. }
  13. //...
  14. });
  1. <div ng-controller="MainCtrl">
  2. <p>{{property}}</p>
  3. <input type="text" ng-model="lsValue"/>
  4. <button ng-click="update(lsValue)">update</button>
  5. <button ng-click="unbind()">unbind</button>
  6. </div>

deriveKey

Return the derive key Returns String

  1. myApp.controller('MainCtrl', function($scope, localStorageService) {
  2. //...
  3. localStorageService.set('property', 'oldValue');
  4. //Test Result
  5. console.log(localStorageService.deriveKey('property')); // ls.property
  6. //...
  7. });

length

Return localStorageService.length, ignore keys that not owned. Returns Number

  1. myApp.controller('MainCtrl', function($scope, localStorageService) {
  2. var lsLength = localStorageService.length(); // e.g: 7
  3. });

Cookie

Deal with browser's cookies directly.

cookie.isSupported

Checks if cookies are enabled in the browser. Returns: Boolean

  1. myApp.controller('MainCtrl', function($scope, localStorageService) {
  1. //...
  1. if(localStorageService.cookie.isSupported) {
  2. }
  3. //...
  4. });

cookie.set

Directly adds a value to cookies.
Note: Typically used as a fallback if local storage is not supported.
Returns: Boolean

  1. myApp.controller('MainCtrl', function($scope, localStorageService) {
  2. //...
  3. function submit(key, val) {
  4. return localStorageService.cookie.set(key, val);
  5. }
  6. //...
  7. });

Cookie Expiry Pass a third argument to specify number of days to expiry

  1. localStorageService.cookie.set(key,val,10)

sets a cookie that expires in 10 days. Secure Cookie Pass a fourth argument to set the cookie as secure W3C

  1. localStorageService.cookie.set(key,val,null,false)

sets a cookie that is secure.

cookie.get

Directly get a value from a cookie.
Returns: value from local storage

  1. myApp.controller('MainCtrl', function($scope, localStorageService) {
  2. //...
  3. function getItem(key) {
  4. return localStorageService.cookie.get(key);
  5. }
  6. //...
  7. });

cookie.remove

Remove directly value from a cookie.
Returns: Boolean

  1. myApp.controller('MainCtrl', function($scope, localStorageService) {
  2. //...
  3. function removeItem(key) {
  4. return localStorageService.cookie.remove(key);
  5. }
  6. //...
  7. });

cookie.clearAll

Remove all data for this app from cookie.
Returns: Boolean

  1. myApp.controller('MainCtrl', function($scope, localStorageService) {
  2. //...
  3. function clearAll() {
  4. return localStorageService.cookie.clearAll();
  5. }
  6. });

Check out the full demo at http://gregpike.net/demos/angular-local-storage/demo.html

Development:

  • Don't forget about tests.
  • If you're planning to add some feature please create an issue before.

Clone the project:

  1. $ git clone https://github.com/<your-repo>/angular-local-storage.git
  2. $ npm install
  3. $ bower install

Run the tests:

  1. $ grunt test

Deploy:
Run the build task, update version before(bower,package)

  1. $ npm version patch|minor|major
  2. $ grunt dist
  3. $ git commit [message]
  4. $ git push origin master --tags
  1. //本地缓存操作
    $scope.localSave = app.localSave = function (key,value) {
    localStorageService.set(key,value);
    localStorageService.cookie.set(key,value);
  2.  
  3. };
    $scope.localGet = app.localGet = function (key) {
    return localStorageService.get(key) ||
    localStorageService.cookie.get(key);
    };
    $scope.localRemove = app.localRemove = function (key) {
    localStorageService.remove(key);
    localStorageService.cookie.remove(key);
    };
    $scope.urlGet = app.urlGet = function (key) {
    var url_pid=window.location.search.substring(1);
    var pairs = url_pid.split("&");
    var urlinfo={};
    for(var i = 0; i < pairs.length; i++) {
    var pos = pairs[i].indexOf('=');
    urlinfo[pairs[i].substring(0,pos)]=pairs[i].substring(pos+1);
    }
    return urlinfo[key];
  4.  
  5. };
    $scope.sessionGet = app.sessionGet = function(key){
    if(window.sessionStorage){
    var item = window.sessionStorage[key];
    if(item){
    return JSON.parse(item);
    }else{
    return item;
    }
    }else{
    return $scope.localGet(key);
    }
    return undefined;
    }
    $scope.sessionSave = app.sessionSave = function(key,value){
    if(window.sessionStorage){
    window.sessionStorage[key] = angular.toJson(value);
    }else{
    $scope.localSave(key,value);
    }
    }
    $scope.sessionRemove = app.sessionRemove = function(key){
    if(window.sessionStorage){
    window.sessionStorage[key] = undefined;
    }else{
    $scope.localRemove(key);
    }
    }
  1.  

本地存储 cookie,session,localstorage( 二)angular-local-storage的更多相关文章

  1. 本地存储 cookie,session,localstorage( 一)基本概念及原生API

    http://www.w3school.com.cn/html5/html_5_webstorage.asp http://adamed.iteye.com/blog/1698740 localSto ...

  2. jquery访问浏览器本地存储cookie,localStorage和sessionStorage

    前言:cookie,localStorage和sessionStorage都是浏览器本地存储数据的地方,其用法不尽相同:总结一下基本的用法. 一.cookie 定义: 存储在本地,容量最大4k,在同源 ...

  3. 本地存储常用方式 localStorage, sessionStorage,cookie 的区别 和 服务器存储session

    本地存储:把一些信息存储到客户端本地(主要目的有很多,其中有一个就是实现多页面之间的信息共享)       1. 离线缓存(xxx.manifest)  H5处理离线缓存还是存在一些硬伤的,所以真实项 ...

  4. 本地存储sessionStorage 、 localStorage 、cookie整理

    sessionStorage . localStorage .cookie 的区别 sessionStorage 和 localStorage 是HTML5 Web Storage API 提供的,可 ...

  5. H5新特性 本地存储---cookie localStorage sessionStorage

    本地存储的作用 :避免登录网站时,用户在页面浏览时重复登录,也可以实现快速登录,一段时间内保存用户的登录效果,提高页面访问速率 在html5中提供三种数据持久化操作的方法: 1.cookie 可看作是 ...

  6. 地理位置(navigation.geolocation)与本地存储(seessionStorage、localStorage)

    一.地理位置( geolocation ): navigator.geolocation对象: 1.单次请求: //navigator.geolocation.getCurrentPosition( ...

  7. 常用的本地存储-----cookie篇

    1.引言 随着浏览器的处理能力不断增强,越来越多的网站开始考虑将数据存储在「客户端」,那么久不得不谈本地存储了. 本地存储的好处: 一是避免取回数据前页面一片空白,如果不需要最新数据也可以减少向服务器 ...

  8. javascript的本地存储 cookies、localStorage

    一.cookies 本地存储 首先是常用的cookies方法,网上有很多相关的代码以及w3cSchool cookies. // 存储cookies function setCookie(name,v ...

  9. 浏览器存储(cookie、localStorage、sessionStorage)

    互联网早期浏览器是没有状态维护,这个就导致一个问题就是服务器不知道浏览器的状态,无法判断是否是同一个浏览器.这样用户登录.购物车功能都无法实现,Lou Montulli在1994年引入到web中最终纳 ...

随机推荐

  1. memcached与.NET的融合使用2

    memcached与.NET的融合使用(二) memcached部署完成之后,对当前缓存中数据的监控就显得比较迫切,这里看到网上开源的memadmin比较小巧好用,决定用它来查看监控memcached ...

  2. JavaScript实例技巧精选(14)—动态变化背景颜色

    >>点击这里下载完整html源码<< 这是截图: 网页背景颜色随时间变化,核心代码如下: <SCRIPT LANGUAGE="JavaScript"& ...

  3. Effective C++(15) 在资源管理类中提供对原始资源的访问

      问题聚焦:     资源管理类是为了对抗资源泄露.     如果一些函数需要访问原始资源,资源管理类应该怎么做呢?        关于资源管理的概念总是显得那么的高大上,其实只是抽象一点. 下面用 ...

  4. 一个小团队TDD游戏及实践

    介绍的这个游戏是自己根据目前带的团队的实际情况来制定的, 在游戏实践过程中,收到了较好的效果,故打算把这个游戏分享出来,一是分享一下实践,而是集思广益,不断完善,更好的利用游戏来锻炼队伍.下面就将游戏 ...

  5. C/C++基础知识总结——数组、指针域、字符串

    1. 数组 1.1 数组作为函数参数 (1) 如果使用数组作为函数的参数,则实参和形参都是数组名,且类型要相同.数组名做参数时传递的是地址 (2) 使用方法: void rowSum(int a[][ ...

  6. .NET核心代码保护策略

    .NET核心代码保护策略-隐藏核心程序集 经过之前那个道德指责风波过后也有一段时间没写博客了,当然不是我心怀内疚才这么久不写,纯粹是程序员的通病..怎一个懒字了得,本来想写一些长篇大论反讽一下那些道德 ...

  7. HTML5 拖拽效果实现

    <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...

  8. 使用brew安装软件

    使用brew安装软件 brew 又叫Homebrew,是Mac OSX上的软件包管理工具,能在Mac中方便的安装软件或者卸载软件, 只需要一个命令, 非常方便 brew类似ubuntu系统下的apt- ...

  9. 对无返回值、使用Action或Func作为参数、多重载的方法进行单元测试

    VS2012 Unit Test(Void, Action, Func) —— 对无返回值.使用Action或Func作为参数.多重载的方法进行单元测试 [提示] 1. 阅读文本前希望您具备如下知识: ...

  10. JavaScript 实现文本编辑器

    JavaScript 实现文本编辑器 最近,我需要做一个非常基本的网页内容编辑功能.我不想使用 iframe ,我也不想要一个功能特别多的复杂编辑器,只需要很基本的内容编辑功能,例如粗体,斜体,列表, ...