Search code examples
javascripthtmlangularjsangularjs-scope

Object not accessible in AngularJS view. Strange behavior


I can't access an object property in AngularJS view. Simple but very crazy issue.

Here is a fiddle: Fiddle

Code below. operators.date and operators.boolean are not available in AngularJS view. How do I access the property?

$scope.operators = {
    date: {'$lt':'before', '$gt':'after', '$eq':'equals'},
    boolean: {'$eq': 'is'},
    all : ['before', 'after', 'contains', 'does not contain', 'equals' ]
};

Solution

  • As commented above, this is an issue with the property names starting with $. When using the {{ }} directive, angular will not show nested $ variables. And in general the team warns against using variables beginning with $. See AngularJS and its use of Dollar Variables