data-ng-init angular

data-ng-init angular

The "data-ng-init" are used to initialize the application data and it's also called to ng-init and does not create a new scope and it's used to evaluate an expressions in the current scope.

The example angular array code as given below.

[{name:'Anil Singh',city:'Noida, India'},
{name:'Sunil ',city:'UP India'},
{name:'code-sample.com',city:'www'}]

The example HTML code as given below.

<div data-ng-init="details=[{name:'Anil Singh',city:'Noida, India'},{name:'Sunil ',city:'UP'},{name:'code-sample.com',city:'www'}]">
        <ul>
            <li data-ng-repeat="detail in details">
               {{detail.name}} : {{detail.city}}
            </li>
        </ul>
    </div>

The full live code as given below.

<!DOCTYPE html>
<html>
<head>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js"></script>
</head>
<body ng-app>
    <div data-ng-init="details=[{name:'Anil Singh',city:'Noida, India'},{name:'Sunil ',city:'UP'},{name:'code-sample.com',city:'www'}]">
        <ul>
            <li data-ng-repeat="detail in details">
               {{detail.name}} : {{detail.city}}
            </li>
        </ul>
    </div>
</body>
</html>

The live output demo : go to below link
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.