1

I am new to AngularJS and currently, I am doing controllers in AngularJS, but I don't know I got an error angular is not defined Line number 21 if someone knows the issue inform me.

<!DOCTYPE html>
<html lang="en" ng-app="myLangApp">
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Document</title>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.8.2/angular.min.js" integrity="sha512-7oYXeK0OxTFxndh0erL8FsjGvrl2VMDor6fVqzlLGfwOQQqTbYsGPv4ZZ15QHfSk80doyaM0ZJdvkyDcVO7KFA==" crossorigin="anonymous" referrerpolicy="no-referrer" async></script>
    </head>
    <body>
        <div ng-controller="language">
            Select your favorite language:
            <button ng-click="selectLanguage('PHP')">PHP</button>
            <button ng-click="selectLanguage('javascript')">javascript</button>
            <button ng-click="selectLanguage('cpp')">cpp</button>
            <button ng-click="selectLanguage('java')">java</button>

            <p>You have selected: {{ myFavLang }}</p>
        </div>
        <script>
            var app = angular.module('myLangApp', []);
            app.controller('language',($scope)=>{
                $scope.myFavLang = 'None';
            })
        </script>
    </body>
</html>

2
  • @MrJami Do you mean Where I import angular js? Commented Nov 10, 2021 at 10:34
  • use this reference for the head script <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script> Commented Nov 10, 2021 at 10:34

1 Answer 1

1

just add simple script to load the angular

<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.8.2/angular.min.js" ></script>
Sign up to request clarification or add additional context in comments.

1 Comment

thank you for your valuable time now that works fine thank you again and have a good day.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.