小编Ait*_*iow的帖子

如何在AngularJS中对两个字段求和并在标签中显示结果?

我的页面上有一个情况.

我的页面中有两个输入和一个标签.这些标签必须显示这两个输入值的总和.

所以我试过以下解决方案:

Sub-Total
<input type="text" ng-model="Property.Field1" />
Tax
<input type="text" ng-model="Property.Field2" />
Total
<label>{{ Property.Field1 + Property.Field2  }}</label>
Run Code Online (Sandbox Code Playgroud)

在第一时间,当页面加载完全以,标签显示的总和,但是当我在任何输入键入一些值, 这些soution给我的串联结果 Property.Field1Property.Field2,而不是总和.

所以我尝试了这些:

Sub-Total
<input type="text" ng-model="Property.Field1" />
Tax
<input type="text" ng-model="Property.Field2" />
Total
<label>{{ parseFloat(Property.Field1) + parseFloat(Property.Field2)  }}</label>
Run Code Online (Sandbox Code Playgroud)

再没有成功.

如何实现标签中显示的两个输入的总和结果?

html javascript sum angularjs

44
推荐指数
4
解决办法
9万
查看次数

Angularjs - 如何在<tr>中有条理地应用不同的类来重复指令

我需要<tr>根据$indexrepeat指令将不同的类应用于a .例如

<table>
   <tr ng-repeat="model in list" class="xxx">
       <td>...</td>
   <tr>
</table>
Run Code Online (Sandbox Code Playgroud)

我需要<tr>根据索引是偶数还是奇数来应用不同的样式.

我该怎么解决这个问题?

indexing repeat angularjs

10
推荐指数
2
解决办法
1万
查看次数

发布webgrid asp.net mvc3的项目

我有这些DTO

public class Header
{
    public int HeaderId{get;set;}
    public int Description{get;set;}
    public List<HeaderItem> HeaderItems{get;set;}

}

public class HeaderItem
{
    public int HeaderItemId{get;set;}
    public string DetailDescription{ get; set; }
    public bool Selected{ get; set; }
}
Run Code Online (Sandbox Code Playgroud)

我有这个控制器

    [HttpPost]
    public ActionResult PostMethod(Header dto)
    {
        ...
    }
Run Code Online (Sandbox Code Playgroud)

和这个HTML

  @using (Html.BeginForm("PostMethod", "Controller", FormMethod.Post, new { id = "form" }))

{

@Html.TextBoxFor(x => x.Description)    

var grid = new WebGrid(Model.HeaderItems);
    }
    @grid.GetHtml(tableStyle: "grid",
    htmlAttributes: new { id = "grid" },
    columns: grid.Columns(
    grid.Column("Selected", "Seç", format: (item) …
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc webgrid asp.net-mvc-3

4
推荐指数
1
解决办法
2261
查看次数

在ASP.NET MVC中POST后消息反馈的最佳实践

我想在POST后找到一个好的方法来反馈消息.

例如,我有这些方法

    public ActionResult Index(int id)
    {
        Model model = getModel(id);           

        return View(model);
    }

    [HttpPost]
    public ActionResult Save(Model model)
    {

        Result result = saveModel(result)

        if (Result.Status != Status.SUCCESS)
        {
            ...
        }
        else if(Result.Status != Status.FAILURE)
        {
            ...
        }else
        {
            ...
        }
        return RedirectToAction("Index");
    }
Run Code Online (Sandbox Code Playgroud)

和Result类有一个消息属性

        public class Result
        {
           ...
           public string Message{get;set;}
        }
Run Code Online (Sandbox Code Playgroud)

因此,当我调用.../Controller/Index/1时,我的索引视图显示,并且此视图有一个调用Save Action的提交按钮,但如果业务层出现问题,我想提出错误/警告消息.

所以,doult是解决这种情况的最佳方法是什么?

我读过一些推荐TempData的文章,其他人推荐使用ViewData,将邮件传输到Index View.

c# asp.net-mvc-3

3
推荐指数
1
解决办法
3560
查看次数

使用具有字符串属性数组的复杂模型作为参数重定向到Action

我遇到了一个问题,我有google却找不到解决方法。

我有这两个动作

    public ActionResult ActionA(DTOA dtoA)
    {
       .....
    }

    [HttpPost]
    public ActionResult ActionB(DTOB dtoB)
    {
        DTOA dto = new DTOA();
        dto.ArraOfStringA = dtoB.ArraOfStringB;
        dto.Id = dtoB.Id;


        return RedirectToAction("ActionA", dto);
    }
Run Code Online (Sandbox Code Playgroud)

模型

public class DTOA
{
    public int Id{get;set;}
    public string[] ArraOfStringA { get; set; }

}

public class DTOB
{
    public int Id{get;set;}
    public string[] ArraOfStringB { get; set; }

}
Run Code Online (Sandbox Code Playgroud)

所以情况是

当我发布到ActionB时,dtoB参数的字符串数组填充有2个itens。“ 1”和“ 2”

但是当此操作重定向到ActionA时,dtoA参数将填充1个itens。“ System.String []”。

如果我在浏览器中输入“ domain / controler / ActionA?ArraOfStringA = 1&ArraOfStringA = 2”

dtoA参数填充了两个iten。“ 1”和“ …

c# asp.net-mvc asp.net-mvc-3

3
推荐指数
1
解决办法
1448
查看次数