Friday, December 5, 2014

AngularJS alert message box using $window

hi in this post i will show how to show an alert box in angularJS using $window element

Code :
<!DOCTYPE html>
<html xmlns=”http://www.w3.org/1999/xhtml”&gt;
<head>
<title></title>
<script src=”//ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.min.js”></script>
<script type=”text/javascript”>
function homeController($scope, $window)
{
$scope.showalert = function ()
{
$window.alert($scope.name);
}
}
</script>
</head>
<body>
<div ng-app=”” ng-controller=”homeController”>
<input type=”text” ng-model=”name” />
<button type=”submit” ng-click=”showalert()”>Submit</button>
</div>
</body>
</html>
output:
1

No comments:

Post a Comment