index.js
var app = angular.module('test', []);
app.controller('MainCtrl', function($scope) {
$scope.name = 'World';
$scope.search = function (artist) {
$.getJSON("https://kmdata.osu.edu/people/chu.472.json",function(data) {
var items = [];
$.each(data, function (key, val) {
items.push("<li id='" + key + "'>" + val + "</li>");
});
$("<ul/>", {
"class": "my-new-list",
html: items.join("")
}).appendTo("body");
});
$scope.artist = artist;
};
});
index.html
<!DOCTYPE html>
<html ng-app="test">
<head>
<meta charset="utf-8" />
<title>AngularJS Test</title>
<script>document.write('<base href="' + document.location + '" />');</script>
<link rel="stylesheet" href="lib/font-awesome/css/font-awesome.css" />
<link rel="stylesheet" href="css/site.css" />
<script data-require="angular.js@1.4.x" src="https://code.angularjs.org/1.4.9/angular.js" data-semver="1.4.9"></script>
<script src="lib/jquery/dist/jquery.js" type="text/javascript"></script>
<script src="JS/index.js"></script>
</head>
<body ng-controller="MainCtrl">
<p>{{iconList[0].name + " " + iconList[0].desc }}</p>
<div class="system-iconbar btn">
</div>
<div>{{"artist:" + artist}}</div>
<input ng-model="artistBox">
<button ng-click="search(artistBox)">Search</button>
</body>
</html>
No comments:
Post a Comment