1

I have some controller with requests for filter, In database my table is sale/rent (it is not my idea, it is too late change name ow table). I am trying to show some objects by this line:

$scope.sale/rent = 'Sale';

Without escape slash i got an error: Uncaught ReferenceError: Invalid left-hand side in assignment.

Ok, just escape this slash like this right?

$scope.sale/\/rent = 'Sale';

But no luck, still got error: Uncaught SyntaxError: Invalid or unexpected token Uncaught SyntaxError: Invalid or unexpected token.

I don't understand how to escape slash here and make an request. Help please, thank you!

Alex
  • 73
  • 1
  • 8

1 Answers1

1

I think this is less an Angular-specific issue and more of a Javascript one-- if you're dealing with non-alphanumeric characters in a property name, you can use square bracket notation:

$scope["sale/rent"] = 'Sale';

I should specify, though-- I'm not really sure how/if the template will consume it properly...

edit: Here is a StackOverflow discussing how to access square bracket properties in templates.

Community
  • 1
  • 1
Alexander Nied
  • 12,804
  • 4
  • 25
  • 45