Check if an object has a property

angularjs, object

Solution

You could use 'hasOwnProperty' to check if object have the specific property.

if($scope.test.hasOwnProperty('bye')){
  // do this   
}else{
  // do this then
}

Here's a demo in jsFiddle.

Hope this helpful.

Problem

How can I check if an object has a certain property in AngularJS?

Original source

Related problems