Skip to content

Commit dc0c49f

Browse files
committed
Complete the feature to render words in the page from json file
1 parent 8eec5e1 commit dc0c49f

File tree

4 files changed

+61
-11
lines changed

4 files changed

+61
-11
lines changed

.gitignore

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
1-
node_modules/
2-
bower_components/
1+
2+
/node_modules/*
3+
/app/bower_components/*
4+
5+
/app/styles/main.min.css
6+
/app/styles/main.css

app/index.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@
77
<script src="bower_components/angularjs/angular.min.js"></script>
88
<script src="scripts/app.js"></script>
99
</head>
10-
<body ng-app="abstackVarLib">
10+
<body ng-app="abstackVarLib" ng-controller="mainCtrl">
1111
<header>
1212
Abstack Tech Variables Library
1313
<input type="text" class="search-box" placeholder="Type some keywords...">
1414
</header>
15-
<ul class="word-list">
16-
<li>
17-
<h3><button class="btn-copy">COPY</button><a href="javascript:;">Settings</a></h3>
15+
<ul class="word-list ng-hide" ng-show="wordsList">
16+
<li ng-repeat="word in wordsList">
17+
<h3>
18+
<button class="btn-copy">COPY</button>
19+
<a target="_blank" ng-href="{{ word.url?word.url: 'http://www.dict.cn/' + word.word }}" ng-bind="word.word"></a>
20+
</h3>
1821
<span class="tag-box">
19-
<em>设置</em>
20-
<em>设置</em>
21-
<em>设置</em>
22-
<em>设置</em>
22+
<em ng-repeat="tag in word.tags track by $index" ng-bind="tag"></em>
2323
</span>
2424
</li>
2525
</ul>

app/json/words.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
[
2+
{
3+
"word": "settings",
4+
"url": "http://www.dict.cn/settings",
5+
"tags": ["设置", "设定", "偏好"]
6+
},
7+
{
8+
"word": "settings",
9+
"url": "http://www.dict.cn/settings",
10+
"tags": ["设置", "设定", "偏好"]
11+
},
12+
{
13+
"word": "settings",
14+
"url": "http://www.dict.cn/settings",
15+
"tags": ["设置", "设定", "偏好"]
16+
},
17+
{
18+
"word": "settings",
19+
"url": "http://www.dict.cn/settings",
20+
"tags": ["设置", "设定", "偏好"]
21+
},
22+
{
23+
"word": "settings",
24+
"url": "http://www.dict.cn/settings",
25+
"tags": ["设置", "设定", "偏好"]
26+
},
27+
{
28+
"word": "settings",
29+
"url": "http://www.dict.cn/settings",
30+
"tags": ["设置", "设定", "偏好"]
31+
},
32+
{
33+
"word": "settings",
34+
"url": "http://www.dict.cn/settings",
35+
"tags": ["设置", "设定", "偏好"]
36+
}
37+
]

app/scripts/app.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,13 @@
33
*
44
* Description: main
55
*/
6-
angular.module('abstackVarLib', []);
6+
angular.module('abstackVarLib', [])
7+
.controller('mainCtrl', ['$http', '$scope', function($http, $scope){
8+
9+
$http.get('/json/words.json')
10+
.success(function(data){
11+
$scope.wordsList = data;
12+
});
13+
14+
15+
}]);

0 commit comments

Comments
 (0)