Asp.net mvc Angular.js在单击按钮时更改表格数据
我已经开始在mvc中使用Angular.js进行编码,我遇到了一个问题:如何让表中的数据在按钮单击时从提醒更改为客户信息?假设我在单击客户时查看信息页面中的数据,在单击提醒时希望从提醒表中获得数据。我还有一个问题,搜索正在计算数据库中的数字,但不是表过滤后显示的数字。任何帮助都将不胜感激。此外,如果有人知道如何进行简单分页,那将非常感谢Asp.net mvc Angular.js在单击按钮时更改表格数据,asp.net-mvc,angularjs,Asp.net Mvc,Angularjs,我已经开始在mvc中使用Angular.js进行编码,我遇到了一个问题:如何让表中的数据在按钮单击时从提醒更改为客户信息?假设我在单击客户时查看信息页面中的数据,在单击提醒时希望从提醒表中获得数据。我还有一个问题,搜索正在计算数据库中的数字,但不是表过滤后显示的数字。任何帮助都将不胜感激。此外,如果有人知道如何进行简单分页,那将非常感谢 <script> var MyApp = angular.module('MyApp', []); MyApp.co
<script>
var MyApp = angular.module('MyApp', []);
MyApp.controller('MyAppCtrl', function ($scope) {
$scope.Info = [
{ "date":"23/09/2014","name": "john", "detail": "sssss" },
{ "date": "27/09/2014", "name": "mary", "detail": "gggggg" }
];
$scope.remind = [
{ "date":"23/09/2014", "detail": "milk" },
{ "date": "27/09/2014","detail": "bread" }
];
$scope.sortField = 'name';//starting sort
$scope.reverse = true;
});
</script>
<div class="container" ng-app="MyApp">
<div class="row" style="padding-top: 60px">
<div class="panel panel-warning">
<div class="panel-heading">Home
</div>
<div class="panel-body">
@* left *@
<div class="col-md-4">
<div class="">
<div class="butLay">
@Html.ActionLink("Reminders", "Reminders", null, new { @class = "btn btn-warning btn-md" })
</div>
</div>
<div class="butLay">
@Html.ActionLink("Expected customer", "Expectedcustomer", null, new { @class = "btn btn-info btn-md" })
</div>
</div>
@* Right side*@
<div class="pr col-md-6" ng-controller="MyAppCtrl">
Search:<input ng-model="query" type="text" />
<span class="label label-info">{{Info.length}} </span>
<table class="table table-striped table-hover ">
<thead>
<tr>
<th><a href="" ng-click="sortField = 'date'; reverse = !reverse">Date</a></th>
<th><a href="" ng-click="sortField = 'name'; reverse = !reverse">Name</a></th>
<th><a href="" ng-click="sortField = 'detail'; reverse = !reverse">detail</a></th>
</tr>
</thead>
<tbody>
<tr ng-repeat="custom in Info| filter:query | orderBy:sortField:reverse">
<td>{{custom.date}}</td>
<td>{{custom.name}}</td>
<td>{{custom.detail}}</td>
</tr>
</tbody>
</table>
@*<ul class="pagination pagination-sm">
<li class="disabled"><a href="#">«</a></li>
<li><a href="#">1</a></li>
<li><a href="#">2</a></li>
<li><a href="#">3</a></li>
<li><a href="#">4</a></li>
<li><a href="#">5</a></li>
<li><a href="#">»</a></li>
@*</ul>*@
</div>
</div>
<table class="table table-condensed table-hover table-striped"></table>
</div>
@* of panel *@
</div>
@*of row*@
</div>
@* of container *@
var MyApp=angular.module('MyApp',[]);
MyApp.controller('MyAppCtrl',函数($scope){
$scope.Info=[
{“日期”:“2014年9月23日”,“姓名”:“约翰”,“详情”:“SSS”},
{“日期”:“2014年9月27日”,“姓名”:“玛丽”,“详情”:“gggggg”}
];
$scope.remind=[
{“日期”:“2014年9月23日”,“详情”:“牛奶”},
{“日期”:“2014年9月27日”,“详情”:“面包”}
];
$scope.sortField='name';//开始排序
$scope.reverse=true;
});
家
@*左*@
@ActionLink(“提醒”,“提醒”,空,新{@class=“btn btn warning btn md”})
@ActionLink(“预期客户”,“预期客户”,null,新{@class=“btn btn info btn md”})
@*右侧*@
搜索:
{{Info.length}
{{custom.date}
{{custom.name}
{{custom.detail}}
@*
@*
*@
@*面板的*@
@*一排*@
@*集装箱*@
您可以制作两个表格,其中一个有
ng-if="variable==false";
另一个有
ng-if="variable==true";
然后你做一个按钮
ng-click="myfunction(variable)"
在控制器中,你有
$scope.myfunction = function(variable){
if(variable == true){
variable = false;
}else{
variable = true;
}
}
因此,当您单击该变量时,它将设置为true或false,并显示正确的内容
设置应显示的表格的步骤
ng-init="variable==true"
比如说
希望这有帮助那么我说$scope.myfunction=function(提醒,承认){if(提醒==true){Admissions=false;}否则{Admissions=true;}}和Admissions,emissions和ng init=“提醒==true”ng if=“提醒==true”对吗在一个表上,在另一个表上为ng if=“Admissions==false”