Hello i have two similar code. One is working, the other one does not work.
Below is working code :
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml";>
<head>
    <title>Welcome in the AngularJS</title>
    <script 
src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js";></script>
</head>
<body ng-app="app">
    <div ng-controller="forEachController">
        <p ng-repeat="pr in prop">Properties: {{pr}}</p>
        <p ng-repeat="vl in val">Value: {{vl}}</p>
        {{obj}}
    </div>
</body>
</html>
<script>
    var app = angular.module("app", []);
    app.controller('forEachController', ['$scope', function ($scope) {
        $scope.prop = [];
        $scope.val = [];
        $scope.obj = [];
        angular.forEach([{ name: 'Todd', location: 'UK' },{ name: 'Todd', 
location: 'UK' }], function (value, prop, obj) {
            $scope.val.push(value);
            $scope.prop.push(prop);
            $scope.obj.push(obj);
        });
    }]);

</script>




Below does not work. I couldn't solve it. How could i fix that and get a 
similar result with the above working code?
<!DOCTYPE html>  
<html ng-app="" xmlns="http://www.w3.org/1999/xhtml";>    
<head>  <!-- www.techstrikers.com -->  
<title>My first AngularJS code</title>    
<script 
src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js";></script>
</head>    
<body bgcolor="#bnde45">  
 
 
<script>    
angular.forEach([{ name: 'Todd', location: 'UK' },{ name: 'Todd', location: 
'UK' }], function (value, prop, obj) {
document.write(value);
document.write(prop);
document.write(obj);
});
</script>  
</body>    
</html>


-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to