How to ng-repeat through returned items by calling a function on ng-init?

How to ng-repeat through returned items by calling a function on ng-init?

The live demo example code (HTML + AngularJs) as given below

<html>
<head>
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js"></script>
    <script>
        var parentApp = angular.module("myApp", []);
        parentApp.controller("MyController", function ($scope) {
            var userDetail = {
                ID: 1,
                Name: 'Anil Singh',
                Age: 30
            };

            $scope.getUsers = function () {
                return userDetail;
            }
        });
    </script>
</head>
<body ng-app="myApp">
    <h2>User Details</h2>
    <div ng-controller="MyController">
        <div ng-init="user = getUsers()">
            <div>ID : {{user.ID}}</div>
            <div>Name : {{user.Name}}</div>
            <div>Age : {{user.Age}}</div>
        </div>
    </div>
</body>

ANIL SINGH

Anil Singh is an author, tech blogger, and software programmer. Book writing, tech blogging is something do extra and Anil love doing it. For more detail, kindly refer to this link..
My Blogs - https://code-sample.com and https://code-sample.xyz
My Book1 - BEST SELLING ANGULAR BOOK (INCLUDING ALL VERSIONS 2, 4, 5, 6, 7)
My Book2 - ANGULAR 2 INTERVIEW QUESTIONS BOOK - Both Books are Available on WorldWide.

www.code-sample.com/. Powered by Blogger.