0

I am very new to Angular js. I am trying to alert in angular and want to send ajax request to node server .

Here is code which i tried so far.

As my alert in not working

<!doctype html>
<html>
    <head>
            <link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.2/css/bootstrap-combined.min.css"
          rel="stylesheet">
    <link rel="stylesheet" href="css/mycss.css">
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular.min.js"></script>
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular-resource.min.js"></script>
    </head>
    <body>
    <form action="#">
            <input type="text" ng-model="url">
            <input type="button" ng-click="a()" value="Click here"/>                
  </div>
    </form>

    <script>

        function a() {
            alert("Hello");
        }

    </script>
</body>

</html>
1
  • 3
    You are actually not using angular as you are missing ng-app directive. I suggest you spend 1-2 hours on angular basic. Commented Nov 17, 2014 at 10:27

1 Answer 1

1
<html ng-app> .........

<body ng-controller="personController">
<form action="#">
        <input type="text" ng-model="url">
        <input type="button" ng-click="a()" value="Click here"/>                
</form>
<script>
  function personController($scope) {
     $scope.a = function() {
          alert("Hello");
     }    
  }
</script>

here is the Demo

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.