表单加载如何使用Angular和Mvc4将值从控制器绑定到表 [英] While Form Loading How Can I Bind The Values From Controller To The Table Using Angular And Mvc4

查看:51
本文介绍了表单加载如何使用Angular和Mvc4将值从控制器绑定到表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将控制器中的值绑定到视图中的表格?

我的代码是:





 <   table     class   = 表格表 - 条纹 >  
< thead >
< tr >
< th > 员工ID < / th >
< th > 名称< / th >
< th > 指定< / th >
< th > 移动号码< span class =code-keyword>< / th >
< / tr >
< / thead >
< tbody >

< ; tr data-ng-repeat = emp中的项目 >
< td > {{item.id}} < / td >
< td > {{item.name}} < / td >
< td > {{item.designation}} < / td >
< td > {{item.mobile}} < / td >
< td > < input 类型 = 按钮 data-ng-click = delete(item) = 删除 / > < < span class =code-leadattribute> / td >
< / tr >
< / tbody >
< ; / table >
< span class =code-keyword>< script >
< pre lang = php > $ scope.load = function(){

$ http.get('../ Home / getList')。success(function(emp){
警报(响应);
})。error(函数(响应){
alert('end');
});}
$ scope.load();
< / script >

解决方案

scope.load = function(){


http.get(' ../Home/getList').success(function(emp){
alert(response);
})。error(function(response){
alert('end');
});}


scope.load();
< / script >


How can i bind the values from controller to the table in view?
My code is:


<table class="table table-striped">
            <thead>
                <tr>
                    <th>Employee ID</th>
                    <th>Name</th>
                    <th>Designation</th>
                    <th>Mobile No</th>
                </tr>
            </thead>
            <tbody>

                <tr data-ng-repeat="item in emp">
                    <td>{{item.id}}</td>
                    <td>{{item.name}}</td>
                    <td>{{item.designation}}</td>
                    <td>{{item.mobile}}</td>
                    <td><input type="button" data-ng-click="delete(item)" value="Delete" /></td>
                </tr>
            </tbody>
        </table>
<script>
<pre lang="php">$scope.load = function () {

                $http.get('../Home/getList').success(function (emp) {
                    alert(response);
                }).error(function (response) {
                    alert('end');
                });}
 $scope.load();
</script>

解决方案

scope.load = function () {


http.get('../Home/getList').success(function (emp) { alert(response); }).error(function (response) { alert('end'); });}


scope.load(); </script>


这篇关于表单加载如何使用Angular和Mvc4将值从控制器绑定到表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆