javascript - Angularjs - TypeError: Cannot read property 'name' of undefined" when work with dropdown -
<select id="ddlpropertyname" ng-options="property.name property in allproperty" ng-model="property.name"><option value="">-select name-</option> </select> if there no value selected in dropdown i'm getting below error :( typeerror: cannot read property 'name' of undefined"
js code name: $scope.property.name.name
but want if no value gets selected still can check undefined or null json can set value , code execute without execption
use other model variable instead of property. here in modified html have used selectedproperty
<select id="ddlpropertyname" ng-options="property.name property in allproperty" ng-model="selectedproperty"> <option value="">-select name-</option> </select> note: using label value in array in ngoption selectedproperty hold property type
Comments
Post a Comment