- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2025 01:53 AM
hi
i have used checkbox in portal widget. by default value is checked.
I am trying to get checkbox value , it is displayed as undefined. Ideally value should be retrieved as true. Please suggest.
screenshot:
<label><input type="checkbox" name=user_access" ng-model="data.user_access" ng-checked="true"> User Access</label><br/>
//value in client script
spUtil.addInfoMessage("hi01" + $scope.data.user_access);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2025 02:58 AM
Hello @Ujjwal1 ,
Are you populating the value in the Server Script? If not please add something like this there:
data.user_access = true;
Then you can change the HTML to this (please note there was also a missing double-quote in the "name" attribute, which is fixed below):
<label><input type="checkbox" name="user_access" ng-model="data.user_access">User Access</label>
Regards,
Robert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2025 04:36 AM
Thanks @Robert H - for response. provided solution worked .
Just to know - any reason why below code did not work.
ng-checked="true"
Thanks
Ujjwal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2025 05:25 AM
Hello @Ujjwal1 ,
"ng-model" binds the input to a property on the scope, but you need to defined that property first.
Also, "ng-model" should not be used together with "ng-checked", else there will be unexpected results.
You can find more details in the AngularJS documentation for "ngModel" and "ngChecked". Unfortunately I cannot add the links to this message, else it will be deleted.
Regards,
Robert