简体   繁体   中英

Angular JS. My output should give Hello but it is showing {{message}}

I am new and started practicing Angular JS.

My output should give Hello but it is showing {{message}}

Below is HTML code:

<!DOCTYPE html>
<html ng-app="HelloWorldApp">
<head>
    <script     src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script>
    <script src="hello_world_controller.js"></script>
</head>
<body>
    <div ng-app="HelloWorldApp">
    <div ng-controller="HelloWorldController">
        <p>{{message}}</p>
    </div>
    </div>
</body>
</html>

Below is Angular js code:

angular.module('HelloWorldApp', [])
  .controller("HelloWorldController", ["$scope", function ($scope){
     $scope.message = "Hello";
  }]);

I do not see any error with your code, Check your angular version

DEMO

 angular.module('HelloWorldApp', []) .controller("HelloWorldController", ["$scope", function ($scope) { $scope.message = "Hello"; }]); 
 <!DOCTYPE html> <html ng-app="HelloWorldApp"> <head> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script> <script src="hello_world_controller.js"></script> </head> <body> <div ng-app="HelloWorldApp"> <div ng-controller="HelloWorldController"> <p>{{message}}</p> </div> </div> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM