python ruby-programming-language Smalltalk Vue.js Knockoutjs TypeScript JavaScript, OOPs JavaScript Angular 8,7,6,5,4 and 2 Interview Questions and Answers Angular 8,7,6,5,4 and 2 Interview Questions and Answers Angular 4 Angular 2 AngularJs 1.x NodeJs Perl Programming R Programming RequireJs Rust Programming Backbonejs closure programming language go-programming-language kotlin-programming-language
angularjs ng repeat using json object

Angularjs ng-repeat using JSON object

<!doctype html>
<html ng-app="myapp">
<head>
    <meta charset="utf-8">
    <script src="http://code.angularjs.org/1.1.4/angular.js"></script>
    <script>
        var app = angular.module('myapp', []);

        app.controller('myController', function ($scope) {
            var json = {
                "employees": [{
                    "title": "SE",
                    "description": "This is a hard worker",
                    "weeks": [{
                        "id": 001,
                        "title": "1st Week"
                    }]
                }, {
                    "title": "SR. SE",
                    "description": "This is smart worker",
                    "weeks": [{
                        "id": 002,
                        "title": "2nd Week"
                    }, {
                        "id": 003,
                        "title": "3rd Week"
                    }]
                }, {
                    "title": "Tech Lead",
                    "description": "This is both hard and smart worker",
                    "weeks": [{
                        "id": 004,
                        "title": "4th Week"
                    }, {
                        "id": 005,
                        "title": "5th Week"
                    }]
                }]
            };

            $scope.myscope = json;
        });
    </script>
</head>
<body ng-controller="myController">
    <div ng-repeat="emp in myscope.employees">
        <h3>{{ emp.title }}</h3>
        <p>{{ emp.description }}</p>
        <div ng-repeat="week in emp.weeks">
            {{ week.title }}
        </div>
    </div>
</body>

</html>
ANIL SINGH

Hi there! Welcome to my blog. My name is Anil Singh. I'm a author of this blog. For more detail about me, kindly refer to this link..
My Blogs - http://code-sample.com and http://code-sample.xyz
My Books - Interview Questions and Answers Books- Get Your Book in 15+ Digital Stores Worldwide..

You Might Also Like
www.code-sample.com/. Powered by Blogger.
ASK Questions