Jquery Angularjs使用标签绑定数据并以表单形式传递
我试图用标签标签绑定输入数据,并在POST方法中使用相同的ng模型 但在同一时间,只有一件事是有效的,当我试图传递标签的张贴方法时,它不起作用。 因此,我面临删除带有奇怪uId的项目的问题 --视图代码--Jquery Angularjs使用标签绑定数据并以表单形式传递,jquery,html,angularjs,angularjs-material,Jquery,Html,Angularjs,Angularjs Material,我试图用标签标签绑定输入数据,并在POST方法中使用相同的ng模型 但在同一时间,只有一件事是有效的,当我试图传递标签的张贴方法时,它不起作用。 因此,我面临删除带有奇怪uId的项目的问题 --视图代码-- 它们是范围变量- 将您的代码段替换为以下代码段 $scope.originalStudent = { CustomerId: $scope.uId, Name: $scope.uName, Cou
它们是范围变量- 将您的代码段替换为以下代码段
$scope.originalStudent = {
CustomerId: $scope.uId,
Name: $scope.uName,
Country: $scope.uCountry,
};
正如评论中所建议的,输入的ng模型应该是student.uId、student.uName、student.ucontry
更新的HTML代码-
<div class="row">
<div ng-app="learning" ng-controller="LearnController">
<br />
<form method="post" ng-submit="submitStudnetForm()">
<label>Your ID: {{student.uId}}</label>
<input class="form-control " type="text" ng-model="student.uId" name="CustomerId" />
<label>Your Name: {{student.uName}}</label>
<input type="text" ng-model="student.uName" class="form-control " name="Name" />
<label>Your Country: {{student.uCountry}}</label>
<input type="text" ng-model="student.uCountry" class="form-control " name="Country"/>
<input type="submit" value="Create" />
<a href="~/Home/Delete/{{student.uId}}" class="btn btn-danger">Delete</a>
</form>
</div>
</div>
您的ID:{{student.uId}
您的姓名:{{student.uName}
您的国家:{{student.ucontry}
看看你的控制器,它不应该是ng model=“student.uId”
,ng model=“student.uName”
和ng model=“student.ucontry”
?使用这些ng模型的结果是一样的,一旦我在方法中使用它,它就无法正常工作。他也没有将属性绑定到视图中的$scope.student
对象
$scope.originalStudent = {
CustomerId: $scope.uId,
Name: $scope.uName,
Country: $scope.uCountry,
};
<div class="row">
<div ng-app="learning" ng-controller="LearnController">
<br />
<form method="post" ng-submit="submitStudnetForm()">
<label>Your ID: {{student.uId}}</label>
<input class="form-control " type="text" ng-model="student.uId" name="CustomerId" />
<label>Your Name: {{student.uName}}</label>
<input type="text" ng-model="student.uName" class="form-control " name="Name" />
<label>Your Country: {{student.uCountry}}</label>
<input type="text" ng-model="student.uCountry" class="form-control " name="Country"/>
<input type="submit" value="Create" />
<a href="~/Home/Delete/{{student.uId}}" class="btn btn-danger">Delete</a>
</form>
</div>
</div>