Reputation: 39
Im trying to show an Angularjs's variable value in HTML with the following code:
<div ng-controller="MyTextbox">
<p>Fecha de ultima actualizacion: {{nodeID1}} </p>
Here is the code for my angularjs controller:
angular.module("umbraco").controller("MyTextbox", function ($scope,$routeParams) {
$scope.nodeID1 = "Hello World";
});
But nothing display this way. Any help?
Upvotes: 1
Views: 2397
Reputation: 777
Try:
<!DOCTYPE>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js"></script>
<script>
angular.module("umbraco",[]).controller("MyTextbox", ['$scope', function ($scope, $routeParams) {
$scope.nodeID1 = "Hello World";
}]);
</script>
</head>
<body >
<h1>My Textbook</h1>
<div ng-app="umbraco" ng-controller="MyTextbox">
<p>Fecha de ultima actualizacion: {{nodeID1}}</p>
</div>
</body>
</html>
Upvotes: 0
Reputation: 136144
You need to write ng-app="umbraco"
before ng-controller
directive, or write it on body
/html
tag would be preferable.
Markup
<div ng-app="umbraco" ng-controller="MyTextbox">
<p>Fecha de ultima actualizacion: {{nodeID1}} </p>
</div>
and your app should be
angular.module("umbraco",[]).controller("MyTextbox", function ($scope,$routeParams) {
$scope.nodeID1 = "Hello World";
});
Note
If
$routeParams
has not added mistakenly then your app would beangular.module("umbraco",['ngRoute'])
then you need to additionally addangular-route.js
Upvotes: 1