-1

m=5;
for(var i=0;i<m;i++){ 
   document.write(i); 
}

how output i in Angular

it is not working

$scope.B = [];
        angular.forEach([0, 1, 2, 3], function (value, index) {
            $scope.B.push(value);

        });
QoP
  • 27,388
  • 16
  • 74
  • 74
  • [Take a Look This Link](https://docs.angularjs.org/api/ng/directive/ngRepeat) – MD Ashik Apr 29 '17 at 16:39
  • Please change your second code to a [mcve] – mplungjan Apr 29 '17 at 16:40
  • Same Question [LINK_1](http://stackoverflow.com/questions/11160513/angularjs-ng-options-create-range/11161353#11161353) [Link_2](http://stackoverflow.com/questions/11873570/angularjs-for-loop-with-numbers-ranges) – MD Ashik Apr 29 '17 at 16:46

1 Answers1

2

Your code is fine, the problem you have most be related to something else in your AngularJS application.. Check the console and add more info to the question.

In the loop are added the elements to the array $scope.B and showed in the view using json filter.

Code:

angular
  .module('App', [])
  .controller('DefaultController', ['$scope', function ($scope) {
    $scope.B = [];
    angular.forEach([0, 1, 2, 3], function (value, index) {
        $scope.B.push(value);
    });
  }]);
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.10/angular.min.js"></script>

<div ng-app="App">
  <div class="container" ng-controller="DefaultController">
    {{ B | json }}
  </div>
</div>
Yosvel Quintero
  • 18,669
  • 5
  • 37
  • 46