0

I am learning angularJS, ng-app works ng-model works, but when I try ng-controller, it does not work, the fault is on my side but I am unable to figure out what it is, I am not even trying anything fancy, just trying make the ng-controller work,

what is my mistake in the below code?

HTML :

<div ng-app="">
    <h1 ng-controller="HelloWorldCtrl">{{helloMessage}}</h1>
</div>`

and JS :

function HelloWorldCtrl($scope){
    $scope.helloMessage="Hello World";
}

same problem when run in jsfiddle

1

1 Answer 1

3

var myapp = angular.module('myApp', []);

myapp.controller('HelloWorldCtrl', function($scope){
  $scope.helloMessage = "Hello world";

})
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="myApp">
    <h1 ng-controller="HelloWorldCtrl">{{helloMessage}}</h1>
</div>

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.