Tuesday, January 30, 2018

Write a program for adding a controller in angularJS.

  • Add a controller to your application, and refer to the controller with the ng-controller directive:

Program
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js">
</script>
</head>
<body>
<div ng-app="abc" ng-controller="def">
<input ng-model="name">
</div>
<script>
var app=angular.module('abc',[]);
app.controller('def' , function($scope)
{
$scope.name="Rushi Dave";
});
</script>
</body>
</html>

Output


0 comments:

Post a Comment

Thanks For Commented.

TechTalk