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);
});
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);
});
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>