matthewyarlett / AngularJS-Directive-for-SharePoint-People-Picker

An AngularJS directive that wraps up the Microsoft Client-side people picker
http://matthewyarlett.blogspot.com/2015/04/using-microsoft-client-side-people.html
9 stars 12 forks source link

Set Value in People Picker #7

Open knaveenstar opened 6 years ago

knaveenstar commented 6 years ago

Hi, I have an requirement to set the value in people picker. I am passing the json object, its shows like unresolved user, I want to call the resolve user method after setting the value.

capture

jbhaktul commented 3 years ago

hello, you have to uncomment line 108 in the config.peoplepicker.js file:

//SPClientPeoplePicker.SPClientPeoplePickerDict[pickerId].ResolveAllUsers();

Then when you update your angularjs model with a user - it will automatically validate it. And if you want to validate a input box on page load, I did this:

var userid = _spPageContextInfo.userId; var requestUri = _spPageContextInfo.webAbsoluteUrl + "/_api/web/getuserbyid(" + userid + ")"; $http.get(requestUri, { headers: { 'Accept': 'application/json;odata=verbose' } }).then(function(res){ vm.textboxpp = {'Name':res.data.d.LoginName,'Id':res.data.d.Id,'Title':res.data.d.Title}; });

In my input directive I have ng-model="vm.textboxpp". I am using the controller as syntax method which means not using $scope.