'how to pass parameters in angularjs custom directive for function call
This is my code snippet -
<my-wizard
on-finish="doFinish()"
I am calling on-finish from my-wizard's controller class. It works and doFinish() gets invokes. I want to pass some parameters to doFinish() from the directive controller. What is the way for it?
This is my-wizard directive -
app.directive('myWizard', function () {
return {
restrict: 'EA',
replace: true,
transclude: true,
scope: {
onFinish: '&',
...
}
}
Solution 1:[1]
Where is your onFinish() method getting called?
just pass some data to it in the shape of an object
onFinish({someData: data})
Then retrieve it using the same name of the object property:
function doFinish(someData) {
console.log(someData)
}
The directive definition should also cater the passed argument:
<my-wizard
on-finish="doFinish(someData)"
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | mindthefrequency |
