I'm a beginner to Angularjs, what I'm trying to do is call two different methods from a directive depending on the condition.
My work flow is
- I have a form in a directive
- When i try to add a new record via the form, function in the
directive should call the
save()method - when I try to update a new record, function in the directive should
call the
updatemethod
This is my current code
#new html form (calling the form directive)
<recipe-form recipeForm="recipeFormData" > </recipe-form>
#edit html form (calling the form directive)
<recipe-form recipeForm="recipeFormData" > </recipe-form>
So in my directive I have the following method
#form directive
<form id="signup-form_id" ng-submit="$parent.Update()">
So what I want to do is, when the directive calls from the #new I want the method to be
<form id="signup-form_id" ng-submit="$parent.Create()">
So what I want to do is, when the directive calls from the #edit I want the method to be
<form id="signup-form_id" ng-submit="$parent.Update()">
I was trying to pass the method as a param, but for some reason it didn't work:
#update form
<recipe-form recipeForm="recipeFormData" update="Update()"> </recipe-form>