-1

In angular 1.3, i see we have updateOn : blur etc..

<input 
  type="search" 
  ng-model="searchQuery" 
  ng-model-options="{ updateOn: 'default blur'}">

Question: Can we pass in our own function newFunctionCall with parameters : blur ?? Something like ...

<input 
  type="search" 
  ng-model="searchQuery" 
  ng-model-options="{ newFunctionCall('abc',123,search): 'default blur'}">

So that i can use two different input with different argument with the SAME model . LIKE

<input name="contains"
  type="search" 
  ng-model="searchQuery" 
  ng-model-options="{ newFunctionCall('pqr',456,search): 'default blur'}">

<input name="startsWith"
  type="search" 
  ng-model="searchQuery" 
  ng-model-options="{ newFunctionCall('abc',123,search): 'default blur'}">
Claies
  • 22,124
  • 4
  • 53
  • 77
shrw
  • 1,719
  • 5
  • 27
  • 50
  • Please explain what you expect your app to do – ngasull Dec 18 '14 at 10:45
  • What is newFunctionCall supposed to do? I think you might be looking for ng-init with a custom filter like in [this question](http://stackoverflow.com/questions/14238323/angularjs-nginit-with-filter-override-values) - but I'm not 100% sure what you are trying to achieve. – Amicable Dec 18 '14 at 10:45
  • i want to uses two – shrw Dec 18 '14 at 11:46

1 Answers1

1

Use data- attributes to pass arguments into the scope:

<input 
  type="search" 
  ng-model="searchQuery" 
  ng-model-options="{ updateOn: 'default blur'}"
  data-foo="456" data-bar="pqr">

<input 
  type="search" 
  ng-model="searchQuery" 
  ng-model-options="{ updateOn: 'default blur'}"
  data-foo="123" data-bar="abc">

Use angular.element to get the values:

  angular.element(this).attr("data-foo")

References

Paul Sweatte
  • 24,148
  • 7
  • 127
  • 265