0

I would like to add beginsWith (^=) and endsWith ($=).

E.g., scope.$eval('"abcd" ^= "a"') should return 'true'

Shai Ben-Yehuda
  • 134
  • 1
  • 2
  • 8
  • Just write a function to do that and call the function. [Javascript does not allow custom operators](http://stackoverflow.com/questions/20728460/is-it-possible-to-create-custom-operators-in-javascript/20728490#20728490). – ryanyuyu Mar 17 '15 at 18:31

1 Answers1

1

According to Angular's documentation on expressions, you should use controller\filter:

No function declarations or RegExp creation with literal notation

You can't declare functions or create regular expressions from within AngularJS expressions. This is to avoid complex model transformation logic inside templates. Such logic is better placed in a controller or in a dedicated filter where it can be tested properly.

Or Guz
  • 1,018
  • 6
  • 13