【发布时间】:2015-06-14 14:26:40
【问题描述】:
我是 Angular js 的新手,正在构建我的第一个应用程序以在访问 github API 时显示用户。
这是我正在处理的问题: http://plnkr.co/edit/bJxijtHV4kBmJ3heMxA9?p=preview
<form name="searchUser" ng-submit="Search(userName)">
<input type="search" placeholder="User to find" ng-model="userName"/>
<input type="submit" value="Search" />
</form>
Javascript 代码:
var app = angular.module('myApp', []);
app.controller('MainController', function($scope, $http) {
var Search = function(userName) {
$http.get('https://api.github.com/users/' + userName)
.then(function(response) {
$scope.person = response.data;
});
};
});
请告诉我哪里出错了。这是我的第一个应用程序。请原谅任何愚蠢的错误:)
【问题讨论】: