js:
$scope.hello = "hello world";
html:
<input ng-model="hello">
<label>{{hello}}</label>
It sets the label good on initializing but after that it stop updating. What's wrong?
js:
$scope.hello = "hello world";
html:
<input ng-model="hello">
<label>{{hello}}</label>
It sets the label good on initializing but after that it stop updating. What's wrong?
Here you Go
as per your code there were no clues for errors so i just answered with working code and some definition of 2-way data-binding
The updating is called two-way binding a good feature from angular .
Little Brief about 2 way data binding :-
Two way data binding in angularjs framework is approach to synchronize the data between model and view. What it means that if there is any change happens in model ( Back-end ) then view ( front-end ) will be updated and vice versa.
data binding docs Angular data binding Documentation
Sample Js: -
'use strict';
var app = angular.module('mainApp', []);
app.controller('registerCtrl', ['$scope', function($scope){
$scope.hello='hello world';
}]);
Html :-
<!DOCTYPE html>
<html ng-app="mainApp">
<head>
<link rel="stylesheet" href="style.css">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js"></script>
<script src="script.js"></script>
</head>
<body ng-controller="registerCtrl">
<input type="text" ng-model="hello"/>
{{hello}}
</body>
</html>
You properly Binded to the text box with model