0

I am using below example and it's not printing the value defined in $event

Below is my app.js

var myModule = angular.module("myModule",[])
myModule.controller("myController",function($scope){

    $scope.someName = "test";

})

Below is my html

<html ng-app="myModule">

<head></head>
<body>

<div ng-controller="myController">

  This is Angular JS {{ someName }}
</div>
</body>
</html>

1 Answer 1

1

There are no issues with your code. Make sure you have refered angularjs reference as below

DEMO

var myModule = angular.module("myModule",[])
myModule.controller("myController",function($scope){
   $scope.someName = "test";
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<html ng-app="myModule">
<head></head>
<body>
<div ng-controller="myController">
  This is Angular JS {{ someName }}
</div>
</body>
</html>

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

5 Comments

I have done and strangely it throws ncaught ReferenceError: angular is not defined
Which means you have not refered angularjs script
Please get those <script> and ng-app into their place. Should be in head and body respectively.
@RaphaMex not necessarily
It's my mistake..after adding <script> to angularJS and also my app.js it started working

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.