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

Hey! I'm Anil Singh. I author this blog. I'm Active Blogger, Programmer. I love learning new technologies, programming, blogging and participating the forum discussions more...
My Blogs - http://www.code-sample.com and http://www.code-sample.xyz
My Books - Buy Books Online at Best Prices

You Might Also Like
Post a Comment
www.code-sample.com/. Powered by Blogger.