這是我如何嘗試發送我的文本以上,併發送我的模塊ID到我的js文件。我會喜歡我輸入你寫的文字和你點擊的ID。不會將我的值從按鈕和文本發送到我的js文件
的問題是,它回來,並給了我這樣的:
世界,你好未定義 - 未定義
它看起來會是這樣的:
你好世界3 - Tetetew TWT ewtewt
我想要的是,我需要從按鈕發送LektionerId到我的js文件,同時我發送文本到我的js文件。
JS - 文件位置:
$scope.CheckValue = function() {
console.log("Hello world " + $scope.LektionerId + " - " + $scope.Text);
//$scope.$watch("OpgaveId", function() {
// var url = "/opgaver/CheckOpgave/" + $scope.LektionerId ;
// $http.get(url).success(function (response) {
// $scope.Newslist = response;
// });
//});
}
的index.html
<div ng-repeat="module in Newslist">
<div class="col-md-8">
<input type="text"
ng-model="Text"
class="form-control"
placeholder="Write your answer here"
name="Text" />
<button ng-click="CheckValue()"
ng-init="LektionerId='{{module.Id}}'"
class="btn btn-primary pull-right"
style="margin:6px 0;">
Check your answer
</button>
</div>
</div>
或者我應該嘗試把它所有的形式?
對於你想在'button'中使用'ngModel'? – developer033
這是一個錯誤。它被帶走。 @ developer033 –
@ J.Petersen你可以嘗試把'CheckValue(name)'給它嗎? – Smit