Angular ng-click Directive in Controller
Today, We want to share with you Angular ng-click Directive in Controller.
In this post we will show you AngularJs ng-click Event Example, hear for AngularJS Events: ng-click, ng-show, ng-hide we will give you demo and example for implement.
In this post, we will learn about Angular ng-click Directive demo with an example.
ng-click
The ng-click events directive says to AngularJS what to do when an HTML tags element is howmany times clicked.
AngularJs ng-click Event Example
[php]
Simple Click This Submit button:
The button has been clicked to {{count_no}} times.
Solution of AngularJs All Problems For infinityknow.com
My First Web-Application in angularjs, So I am very happy and 1000+ more then people are used of infinityknow.com
[/php]
ng-click call function with parameter
[php]
Script
var app = angular.module(‘app’, []);
function newCtrl($scope) {
$scope.tasks = [{id:1,’name’:’Angularjs-ng-click’}, {id:2,’name’:’angular ng-click directive’}, {id:3,’name’:’angularjs-infinityknow.com’}];
$scope.removeTaskdelete = function(id){
alert(“New Post Id is “+id);
};
}
[/php]
angularjs ng-click href
[php]
$scope.go = function ( path ) {
$location.path( path );
};
[/php]
angularjs ng-click call directive
[php]
var app = angular.module(‘infinityknowApp’, []); //module define
app.directive(‘myDirective’, function(){
return {
restrict: ‘EA’,
replace: true,
scope: {
eventHandler: ‘&ngClick’
},
template: ‘
‘
};
});
app.controller(‘SimpleCtrl’, [‘$scope’, function($scope) {
$scope.myFirstFunction = function(msg) {
alert(msg + ‘!!! Your first function is call!’);
};
$scope.mySecondFunction = function(msg) {
alert(msg + ‘!!! your second function is call!’);
};
}]);
[/php]
ng-click pass object
[php]
ng-click=”collapseQuestion($event);”
function collapseQuestion($event) {
$event.currentTarget //For basic Example of do something with currentTarget
}
[/php]
We hope you get an idea about Angular ng-click Directive in Controller
We would like to have feedback on my Information blog .
Your valuable any feedback, Good question, Inspirational Quotes, or Motivational comments about this article are always welcome.
If you liked this post, Please don’t forget to share this as Well as Like FaceBook Page.
We hope This Post can help you…….Good Luck!.