Monday, 6 November 2023

Using AngularJS create a SPA that clone the “Hacker News” website.

  

 Using AngularJS create a SPA that clone the “Hacker News” website.

 < html>

<html ng-app="HackerNewsCloneApp">

<head>

    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.8.2/angular.min.js"></script>

</head>

<body ng-controller="NewsController">

    <h1>Hacker News Clone</h1>

 

    <!-- List of News -->

    <ul>

        <li ng-repeat="news in newsList">

            <a href="{{ news.url }}" target="_blank">{{ news.title }}</a>

        </li>

    </ul>

 

    <script>

        var app = angular.module('HackerNewsCloneApp', []);

 

        app.controller('NewsController', function ($scope) {

            $scope.newsList = [

                { title: 'Example News 1', url: 'https://example.com/news1' },

                { title: 'Example News 2', url: 'https://example.com/news2' },

                { title: 'Example News 3', url: 'https://example.com/news3' }

            ];

        });

    </script>

</body>

</html>