一、容許瀏覽器讀取本地數Google Chromehtml
方法a、 Google Chrome應用程序目標位置中添加 chrome.exe --allow-file-access-from-files angularjs
! 注意中間空格(chrome.exe --allow-file-access-from-files)chrome
注意!!! 必須從新啓動電腦,不然無效......若方案一還無效,繼續執行方案二json
方法b、 使用cmd命令 傳入瀏覽器啓動參數 --allow-file-access-from-files瀏覽器
方法c、用啓動瀏覽器打開html文件便可. 若還出現上述問題,重啓電腦,繼續方案二app
二、生成json文件ui
重命名areaList.json3d
三、編輯angularjs目錄cdn
四、源碼xml
index.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="http://cdn.static.runoob.com/libs/angular.js/1.4.6/angular.min.js"></script>
<title>無標題文檔</title>
<script src="./static/index.js"></script>
</head>
<body>
<div ng-app="indexApp" ng-controller="indexCtrl">
名字: <input ng-model="name">
<h1>你輸入了: {{name}}</h1>
</div>
</body>
</html>
index.js
var app = angular.module('indexApp', []);
app.controller('indexCtrl', function($scope,$http) {
$http.get('static/areaList.json').success(function (data) {
$scope.nick = data;
});
$scope.name = "John 111";
});// JavaScript Document
areaList.json
[ { "id": 1, "username": "situ", "gender": "男", "email": "gao_st@126.com" }, { "id": 2, "username": "wb", "gender": "女", "email": "wb@126.com" }, { "id": 3, "username": "lml", "gender": "男", "email": "lml@126.com" }, { "id": 4, "username": "wjd", "gender": "女", "email": "wjd@126.com" }, { "id": 5, "username": "lyl", "gender": "男", "email": "lyl@126.com" }, { "id": 6, "username": "wjh", "gender": "女", "email": "wjh@126.com" } ]