0

I have the code as below which should popup an alert dialog while clicking "Alert AngularJS" button, but it doesn't. Can someone give me some advices?

<html>
    <head>
        <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.14/angular.js"/>
        <script type="text/javascript">
            angular.module('app', []).run(function ($rootScope, $window) {
                $rootScope.myAlert = function () {
                    $window.alert('Hello AngularJS');
                };
            });
        </script>
    </head>
    <body ng-app="app">
        <button ng-click="myAlert()">Alert AngularJS</button>
    </body>
</html>
1
  • Works fine for me... see this jsfiddle (jsfiddle.net/DanielBank/U7t8G). Are you sure that angular is loading? Any errors in the console log? Commented Mar 21, 2014 at 5:33

1 Answer 1

2

The

<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.14/angular.js"/>

should be

<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.14/angular.js"></script>

Sign up to request clarification or add additional context in comments.

Comments

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.