angular.js - Please tell me about the usage examples of array objects in AngularJS.
PHP中文网
PHP中文网 2017-05-15 16:50:09
0
1
638
 self.getNoteClass = function(status) {
    return {
        done: status,
        pending: !status
    };
  };  

I encountered such a usage in the book, the incoming parameter must be true or false, and then passing in true returns done, and false returns pending.
I would like to ask if this usage is a special usage in angularjs? I don’t understand, please give me some answers, thank you!
PS: The following example I wrote myself is a simpler and clearer way of use that I can understand.

self.getClassname = function(string) {
    var obj = {
      '1' : even,
      '2' : odd
    };
    return obj[string];
  };
PHP中文网
PHP中文网

认证高级PHP讲师

reply all(1)
Peter_Zhu

I guess this is meant to be used in conjunction with the ng-class built-in directive, in which case, the className done will be applied to the element when status is true, and className pending will be applied to the element otherwise.

You may see the "Map Syntax Example" section in the document for ng-class for reference.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template