How to Injected to Angular objects?

An object is a block of code that has been allocated or configured according to your custom logic. A program may create many objects of the same class. 

In AngularJs, A controller class can contains many object like module object, array module etc. 

In the below example, I am going to share the how to Inject the objects and use of objects. Please see the detail as given below.

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>injected to Angular objects </title>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.6/angular.min.js"></script>
    <script>
        var app = angular.module('diApp', []);
        app.controller('diCtrl', ['$scope', '$http', function ($scope, $http) {

            $scope.countries = [{
                "name": "India"
            }, {
                "name": "USA"
            }, {
                "name": "Nepal"
            }, {
                "name": "Indonesia"
            }, {
                "name": "Brasil"
            }];
        }]);
    </script>
</head>
<body ng-app="diApp" ng-controller="diCtrl">
    <div>
        <div>
            <div>
                <h2>Country List</h2>
            </div>
        </div>
        <div ng-repeat="country in countries">
            <div> {{country.name}}</div>
        </div>
    </div>
</body>
</html>

About Blogger

ANIL SINGH

Hey! I am Anil Singh. I am Active Blogger, Writer and Programmer. I love learning new technologies, programming, blogging and participating the forum discussions more...
http://www.code-sample.com
http://www.code-sample.xyz

    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment

SQL Server NodeJs TypeScript JavaScript Angular SQL Server My Book