hi in this post i will show how to show an alert box in angularJS using $window element
Code :
Code :
<!DOCTYPE html>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<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>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<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>
</html>
output:
No comments:
Post a Comment