I am attempting to verify the existence of a key within an object in an Angular $scope. Within my controller, I have defined this:
$scope.the_object = {'the_key': 123};
And in my template, I have included the following:
<span ng-if="'the_key' in the_object">
the_key exists in the_object
</span>
However, upon inspection, I encountered the subsequent error in the console:
Error: [$parse:syntax] http://errors.angularjs.org/1.4.7/$parse/syntax?p0=in&p1=is%20an%20unexpected%20token&p2=11&p3='the_key'NaNn%20the_object&p4=in%20the_object
at Error (native)
at http://52.29.xx.xx:5000/bower/angular/angular.min.js?version=1.4.7:6:416
at Object.s.throwError (http://52.29.xx.xx:5000/bower/angular/angular.min.js?version=1.4.7:209:339)
at Object.s.ast (http://52.29.xx.xx:5000/bower/angular/angular.min.js?version=1.4.7:202:118)
at Object.sd.compile (http://52.29.xx.xx:5000/bower/angular/angular.min.js?version=1.4.7:211:203)
at fc.parse (http://52.29.xx.xx:5000/bower/angular/angular.min.js?version=1.4.7:238:193)
at b.$get (http://52.29.xx.xx:5000/bower/angular/angular.min.js?version=1.4.7:117:315)
at n.a.$get.n.$watch (http://52.29.xx.xx:5000/bower/angular/angular.min.js?version=1.4.7:127:125)
at a.link (http://52.29.xx.xx:5000/bower/angular/angular.min.js?version=1.4.7:254:214)
at aa (http://52.29.xx.xx:5000/bower/angular/angular.min.js?version=1.4.7:73:90)
Can anyone advise on how to validate if the_key
is present within the_object
directly within the ng-if statement?