刘黎明
刘黎明

Reputation: 3

Angularjs --can not selected any options

When I use the

<select class="form-control" name="roleId" ng-model="addStaff.roleId" 
ng-options="ur.id as ur.name for ur in UserRole">
    <option value="">请选择</option>
</select>

the console display angular.js:11598 TypeError: Cannot create property 'roleId' on boolean 'true'.

If i use the ng-options the same error is displayed.

Upvotes: 0

Views: 51

Answers (2)

Mohit Tanwani
Mohit Tanwani

Reputation: 6628

Try to initialized the object in your angular controller as below.

$scope.addStaff = { roleId : {}};

May be there is possibility of roleId is already defined as boolean in your code. Try to make is as an object.

Upvotes: 1

Pravin Erande
Pravin Erande

Reputation: 89

Initialise object in controller

$scope.addStaff={};

Upvotes: 0

Related Questions