I want to use monaca's contact plug-in to display a list of contacts.

Asked 2 years ago, Updated 2 years ago, 118 views

I would like to use the angel+monaca contact plug-in to display a list of contacts.

app.controller('MainController', function($scope){

    document.addEventListener("device ready", function(){
         var options = new ContactFindOptions();
         options.filter="";
         options.multiple=true;
         varfields = ["*"];
         contact=navigator.contacts.find(
            fields       
              , function(success) {$scope.contact=success;}
           , function(contactError) {aleat('contactError');}
             , options
          );
    }, false);
      });

<ons-pageing-controller="MainController">
      <ons-list>
        <ons-list-item modulator="chevron" class="item">
          <ons-row>

            <ons-col>
              <header>
                <span class="item-title">{{contact[0].id}}</span>
               ...

It doesn't show at all.What's wrong with you...

monaca onsen-ui cordova angularjs

2022-09-30 20:35

1 Answers

After rewriting js like this, the error no longer appears (I was also able to confirm that it goes into function(success){}).
When using Onsen UI, the description seems a little different from AngularJS (although it may depend on how you do it).

ons.bootstrap()
.controller('MainController', function($scope){
    document.addEventListener('device ready', function(){
        var options = new ContactFindOptions();
        options.filter="";
        options.multiple=true;
        varfields = ["*"];
        contact=navigator.contacts.find(
           fields       
            , function(success) {$scope.contact=success;}
          , function(contactError) {aleat('contactError');}
            , options
        );
    }, false);
});

However, this does not seem to hold the value set in function(success){$scope.contact=success;}, so it may need to be corrected.


2022-09-30 20:35

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.