I am new AngularJS. It's really fun, but I am facing some problem with this expression. This is my code:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<style>
p{
height: 600px;
width: 600px;
font-size:17px;
}
</style>
</head>
<body>
<div ng-app="myApp" ng-controller="editor">
<label for="kys_font_size"> font size:</label>
<select ng-model="kys_selected_font" id="fontsize" name="kys_font_size" ng-options="page for page in FontSize(1, 150)" ng-change="changeFont()">
</select>
<p contenteditable="true" id="content" ng-change="print()" >
</p>
<input type="text" ng-model="name1">
<p >{{name1}}</p>
</div>
<p></p>
<script>
var app = angular.module('myApp',[]);
app.controller('editor',function($scope){
$scope.name1="jpos"
$scope.kys_selected_font = "hi there";
$scope.fonttext="hello";
$scope.FontSize = function(start, end) {
var size = [];
for (var i = start; i <= end; i++) {
size.push(i);
}
return size;
};
$scope.print= function(){
};
$scope.changeFont = function(){
$("#content").append("<b size='3' '> This is some text </b>");
$("#one").focus();
};
});
</script>
</body>
</html>
This gives me an {{Name1}} as output. Can someone please tell me where I have gone wrong with this code?
ng-model="name1"but the lack ofngModelon the element with thengChangedirective. It says in the docs thatngChangealso needsngModelpresent on the same element. So in this case i believe that is apelement.