更新角度控制器中的ng-init

时间:2017-04-21 09:23:57

标签: javascript angularjs

HTML

 <div class="right" data-ng-attr-id=i value="{% verbatim %}{{indexValue}}{% endverbatim %}">
    <img ng-src="{% verbatim %}{{link[indexValue].uploaded_id}}{% endverbatim %}" data-ng-attr-test={{test}} class="img" value="{% verbatim %}{{link[indexValue].uploaded_id}}{% endverbatim %}"
        ng-model="test" ng-init='test= getId()' ng-show="test" /> {% verbatim %}{{analysis_obj.wptId}}{% endverbatim %}
    <div class="bottom-progress">
        <div class="progress">
            <div class="progress-bar" role="progressbar" aria-valuemin="0" aria-valuemax="100" ng-style="progress_style('{{ django_upload_id }}'+{% verbatim %}{{ analysis_obj.wptId }}{% endverbatim %})"></div>
        </div>
    </div>
</div>

JS

for (var i = 1; i <= wptListLength * 5; i++) {
    $scope['img' + i] = true;
    console.log("Gen Values" + $scope['img' + i]);
}

var current = 1;
$scope.getId = function () {

        var j = current;
        console.log("Current in controller for " + 'img' + j + " " + $scope['img' + j]);
        current = current + 1;
        if (current == (wptListLength * 5 + 1)) {
            current = 1;
            j = 1;
        }
return $scope['img'+j];
}

稍后在操作过程中,我会更新$scope['img'+j],如何让它反映在ng-showng-model中。第一个设定值ng-init="test=getId()"如果我想做手表。如何观察动态创建的大量值。

0 个答案:

没有答案