当我在局部视图MVC上创建angular.module时出现问题

时间:2016-09-29 23:25:30

标签: angularjs asp.net-mvc asp.net-mvc-4

嗨我在部分视图上有这段代码:

var app = angular.module('tableConditions', []); app.controller('conditionsRow', function ($scope){

$scope.options = [{ index: 0 }, { index: 1 }, { index: 2 }];

$scope.addNewRow = function () {
    var newItemNo = $scope.options.length;

    conditionCount = conditionCount + 1;
    $scope.options.push({ 'index': '' + newItemNo });
};

$scope.removeOption = function (selfIndex) {
    var lastItem = $scope.options.length;
    if (lastItem > 0) {
        lastItem = lastItem-1;
    };
    conditionCount = conditionCount -1;
    $scope.options.splice(lastItem);
    $scope.options.splice(selfIndex,1);
};

$scope.GetExceptionColumnValues = function (self, index) {
    var accountingUrl = $("#exceptionUrl")[0].value;

    var ValueInput = "#Condition_" + index + " #ConditionValue";

    $.ajax({
        url: accountingUrl,
        method: "GET",
        data: {
            fieldId: self.index,
            tableName: "Fact_IBNR_DUP_UPR_Reserve"
        },
        success: function (data) {
            $(ValueInput).find("option").remove();
            $.each(data.data[0].Result, function () {
                $(ValueInput).append($("<option   />").val(this.ExceptionValue).text(this.ExceptionValue));
            })
        },
        error: function (response, status, xhr) {
        }
    });
};});

当我调用我的局部视图时会调用它,但是如果我在页面上添加了更多的部分视图,这只是第一次工作,这不起作用你知道每次调用的问题是什么:

 @for (int i = 0; i < Model.Exceptions.Count; i++ )
    {
        <div class="row">
            @{Html.RenderAction("AccountingException", "AccountingException", new { exceptionId = Model.Exceptions[i].AccountExceptionId, accountType = Model.AccountingType });}
        </div>
    }

这只是打电话一次,如果你能帮助我,请告诉我

0 个答案:

没有答案