How to use ng-click directive in angularjs

Posted by Manideepgoud under AngularJS 1x category on | Points: 40 | Views : 1389
Here we are using ng-click directive to change the name when the mouse is clicked on the paragraph, we have declared function as clickhere() and we declared firstname as manideep and function clickhere performs changing name when we click on the paragraph and shows the value which we declare.

<div ng-app="myApp" ng-controller="myCtrl">
<p ng-click="clickhere()">{{firstname}}</p>
var app = angular.module('myApp', []);
app.controller('myCtrl', function ($scope) {
$scope.firstname = "Manideep";
$scope.clickhere = function () {
$scope.firstname = "Goud";

Comments or Responses

Login to post response