我正在嘗試學習AngularJS,並在按鈕單擊以在調用http服務時追加到字符串url值之後傳遞用戶輸入的文本框文本值時需要幫助。訪問控制器中的angularjs文本框的值
我想以下面的方式添加,但它顯示了一個未定義的值,同時將URl與用戶從文本框中輸入的文本相加。
這裏是我的HtmlPage1.html
<form ng-submit="abc(inputValue)">
<input type="text" name="name" ng-model="inputValue" />
<button type="submit">Test</button>
</form>
和我的腳本文件的script.js
var app = angular.module("repos", [])
.controller("reposController", function ($scope, $http, $log) {
$scope.inputValue = null;
$scope.abc = function (value) {
$scope.inputValue = value;
};
$http({
method:'GET',
url: 'https://api.github.com/users/'+$scope.inputValue+'/repos'
})
.then(function (response) {
$scope.repos = response.data;
$log.info(response);
});
});
誰能幫助我如何得到正確的價值這方面,用戶已經進入附加到URL?
在此先感謝。