javascript - Angular Js : {{message}} is not replaced by some text -


below simple example trying implement controller.

{{8/2}} giving correct output i.e. 4 {{message}} remains same.

it should replaced value e.g. first controller

i downloaded angular js https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js

html

<!doctype html> <html ng-app>  <head>     <script src="angular.js"></script>   <link rel="stylesheet" href="style.css" />   <script src="script.js"></script> </head>  <body>   <h1>{{8/2}}</h1>   <div ng-controller="homecontroller">       {{message}}    </div> </body> </html> 

script.js

var homecontroller = function($scope) {    $scope.message = "first controller";  }; 

i downloaded angular js https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js

well angularjs version 1.4x not support raw functions controllers used controllers. change angularjs version 1.2.x or use angular.module('somename').controller() syntax make work.

here's same plunkr shared(with angularjs 1.2.8)

here's plnkr angular.module() syntax


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -