Reputation: 5
Hi I have been learning angularjs over a week now. I have a question on ng-model.
my question is I have a field called firstname:. When I give the name and hit the submit button. The firstname has to be displayed in another field called Name:
Here is the code I wrote:
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js">
</script>
<script type="text/javascript">
var emp= angular.module("empdet",[])
emp.controller("empctrl",function($scope){
$scope.form= function(){
var display= $scope.firstname;
}
});
</script>
</head>
<body ng-app="empdet">
<div ng-controller="empctrl">
<div>First Name: <input type="text" ng-model="firstname"></div>
<button type="button" ng-click=form()>SUBMIT</button>
<div>Name:{{display}}</div>
</div>
</body>
</html>
Any help is appreciated.
Thanks
Upvotes: 0
Views: 32