使用带有$ scopes的for循环

时间:2017-05-23 15:13:11

标签: angularjs for-loop

是否可以使用角度范围进行for循环?例如。我有:

$scope.start = 1;
$scope.end = 10;

并希望制作一个(例如我知道它不起作用)

for($scope.start; $scope.start < $scope.end; $scope.start++) {
   print(<input type="radio" name="count" value="$scope.start">);
}

1 个答案:

答案 0 :(得分:0)

<script src="//code.angularjs.org/snapshot/angular.min.js"></script>

<div ng-app='app' ng-controller="MyController">
    start: <input type="text" ng-model='start'>
    </br>
    stop: <input type="text" ng-model='stop'>
    </br>
    interval: <input type="text" ng-model='interval'>
    </br>
    <label ng-repeat-start='item in getTimeArray(start, stop, interval)'>{{item}}</label>
    <input type="radio" name="count" value="{{item}}" ng-repeat-end>
</div>
(...)
onOptionsChange(newState){
        this.setState(newState);
    }
render(){
    return (
        <Options onOptionsChange={(newState) => 
        this.onOptionsChange(newState)} />
        )
}
}
(...)