以角度为单位更改动态值

时间:2017-06-28 22:39:08

标签: angularjs

当我更改表的值但是只需要更改行的值时,我遇到了问题,但这种情况发生在所有行中。

enter image description here 现在,如果我只更改一个值,请更改右侧的所有值。

enter image description here  在html:

    # retrofit
    # Platform calls Class.forName on types which do not exist on Android to determine platform.
    -dontnote retrofit2.Platform
    # Platform used when running on Java 8 VMs. Will not be used at runtime.
    -dontwarn retrofit2.Platform$Java8
    # Retain generic type information for use by reflection by converters and adapters.
    -keepattributes Signature
    # Retain declared checked exceptions for use by a Proxy instance.
    -keepattributes Exceptions
    #okio
    -dontwarn okio.**
    #Picasso
    -dontwarn com.squareup.okhttp.**
    #retrolambda
    -dontwarn java.lang.invoke.*
    -dontwarn **$$Lambda$*

    # Amazon AWS
    -dontwarn com.fasterxml.jackson.core.**
    # Guava
    -dontwarn sun.misc.Unsafe
    -dontwarn java.lang.ClassValue

    -keep class retrofit2.** { *; }
    -keep class com.ool.oolapp.data.models.** {*;}
    -keepclassmembernames interface * {
        @retrofit2.http.* <methods>;
    }
    -keepattributes *Annotation*

现在处于角度,我需要这种情况发生了这个:

<tr ng-repeat="detail in detalleTransCover.details track by $index">
                                    <td>
                                        <select class="form-control" ng-model="detail.plan_account_id" ng-options="planAcoount.id as (planAcoount.tipo_cuenta + ' -- ' + planAcoount.descripcion) for planAcoount in planAccounts"></select>
                                    </td>
                                    <td>
                                        <input type="text" class="form-control" ng-model="detail.glosa" >
                                    </td>
                                    <td>
                                        <input type="text" value="0" class="form-control" ng-model="detail.debeDolar" >
                                    </td>
                                    <td>
                                        <input type="text" value="0" class="form-control" ng-model="detail.haberDolar" >
                                    </td>
                                    <td>
                                        <input type="text" value="0" class="form-control" ng-model="detail.debeBolivianos" >
                                    </td>
                                    <td>
                                        <input type="text" value="0" class="form-control" ng-model="detail.haberBolivianos" >
                                    </td>
                                    <td>
                                        <select class="form-control" ng-model="detail.cuentade" ng-change="subcuentasChange(detail.cuentade)">
                                            <option value="usuario">EMPLEADO</option>
                                            <option value="proveedor">PROVEEDOR</option>
                                            <!--<option value="cliente">CLIENTE</option>
                                            <option value="activo">ACTIVO FIJO</option>-->
                                        </select>
                                    </td>
                                    <td>
                                        <select class="form-control" ng-if="proveedorDropDown" ng-model="detail.plan_account_id" ng-options="proveedor.id as proveedor.razon_social for proveedor in proveedorDatos"></select>
                                        <select class="form-control" ng-if="userDropDown" ng-model="detail.plan_account_id" ng-options="user.id as user.name for user in userDatos"></select>
                                    </td>
                                </tr>

1 个答案:

答案 0 :(得分:0)

$scope.userDropDown = false;
$scope.proveedorDropDown = false;

为所有行声明这两个变量。您需要为每行保留每个detail的值。

我会将功能改为这样的

$scope.subcuentasChange = function (detail)
{
    if(detail.type === 'usuario')
    {
        detail.userDropDown = true;
        detail.proveedorDropDown = false;
    }
    if(detail.type === 'proveedor')
    {
        detail.userDropDown = false;
        detail.proveedorDropDown = true;
    }
};

ng-change="subcuentasChange(detail)"传递给函数。 您可以使用单独的数组来改善这一点。

也相应更改ng-if。我只保留一个标记,例如isProvider而不是两个,并使用ng-show="isProvider"ng-hide="isProvider"进行选择。