在Angular 1.3.16中动态添加输入

时间:2015-08-06 19:49:31

标签: javascript angularjs angularjs-scope angularjs-ng-repeat

我的代码很简单,当我在网上搜索时,我猜这是因为角度1.3.x 我正在尝试创建动态输入,并希望获得数组中的值。 HTML:

var timer: NSTimer?
var timerStartTime: NSTimeInterval = 0.0

func startTimer() {
    timer = NSTimer(... to call myself every second ...)
    timerStartTime = NSDate.timeIntervalSinceReferenceDate()
}

func timerCallback(timer: NSTimer!) {
    let timeSinceTimerBegan = NSDate.timeIntervalSinceReferenceDate() - timerStartTime

    print("It has now been \(timeSinceTimerBegan) seconds since timing began; 
                                        counter should be at \(100 - timeSinceTimerBegan)")
}

JS:

<div class="row" ng-repeat="item in designFormData.perInstallments track by $index">
    <div class="col-md-5">
        <label for="">Installment #{{item.sn}}</label>
    </div>
    <!-- /.col-xs-6 col-sm-4 -->
    <div class="col-md-7">
        <input type="number" class="form-control" id="" autocomplete="off" ng-model="item.price">
    </div>
    <!-- /.col-xs-6 col-sm-4 -->
</div>

问题: 价格没有反映在perInstallments

for (var i = 0; i < noOfInstallments; i++) {
    $scope.designFormData.perInstallments.push({
        sn: i+2,
        price: ""
    });
}

值而不是出现在perInstallments项中,出现在ng-repeat的子范围内。怎么解决这个问题。我已经尝试过按$ index添加曲目了。

任何建议。

0 个答案:

没有答案