A Pen by Eduardo Reche on CodePen.
Created
August 5, 2015 00:33
-
-
Save eduardoreche/6302db667852da0b2485 to your computer and use it in GitHub Desktop.
Callback call in angular ng-click
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div ng-app="testApp"> | |
<div ng-controller="myCtrl"> | |
<a href="" ng-click="fA()">Function A</a> <br> | |
<a href="" ng-click="fB('some text', _callback, 'callback text param')">Function B</a> | |
<br> | |
{{text}} | |
</div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('testApp', []) | |
.controller('myCtrl', function($scope) { | |
$scope._callback = function(text) { | |
return text; | |
} | |
$scope.fA = function(){ | |
$scope.text = 'this is function A' ; | |
} | |
$scope.fB = function(text, callback, callback_param) { | |
$scope.text = 'this is function B '+ callback(callback_param) ; | |
} | |
$scope.text = ''; | |
}); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.14/angular.min.js"></script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment