https://angular.carbondesignsystem.com/?path=/story/components-combobox—basic

组件及属性

  • Input
    • placeholder
    • openMenuAria
    • closeMenuAria
    • clearSelectionsTitle
    • clearSelectionsAria
    • clearSelectionTitle
    • clearSelectionAria
    • id
    • items
    • type
    • size
    • itemValueKey
    • label
    • helperText
    • appendInline
    • invalid
    • invalidText
    • warn
    • warnText
    • maxLength
    • theme
    • selectionFeedback
    • autocomplete
    • dropUp
    • disabled
  • Output
    • selected
    • submit
    • close
    • search
  • HostBinding

    • style.display = block

      Tips

      when use public or protected or default

      根绝这个文章的答案
      https://stackoverflow.com/questions/37506343/private-and-public-in-angular-component
      public/protected/private 是一种明确的标识,如果不需要强调是默认是可以没有的。没有即 public。

      @Input() set placeholder(value: string | Observable) {

      这里这个写法,Observable作为了参数,跟着后面的代码发现, i18n.service.ts 文件中已经针对该类型进行了处理:

      1. /**
      2. * Takes a string or an `Observable` that emits strings.
      3. * Overrides the value provided by the `I18n` service.
      4. */
      5. override(value: string | Observable<string>) {
      6. this.isOverridden = true;
      7. // To ensure that there are not multiple subscriptions created for the same observable, we
      8. // unsubscribe if a subscription already exists for an observable before creating a new one.
      9. if (this.subscription) {
      10. this.subscription.unsubscribe();
      11. this.subscription = null;
      12. }
      13. this._value = value;
      14. // 这里判断了 value 的类型后做处理。
      15. if (isObservable(value)) {
      16. this.subscription = value.subscribe(v => {
      17. this.$override.next(v);
      18. });
      19. } else {
      20. this.$override.next(value);
      21. }
      22. }

      Code

      https://github.com/llccing-demo/carbon-components-angular/blob/master/src/combobox/combobox.component.ts

      感谢

      朋友你好,如果你对我的文章感兴趣,欢迎关注我的 Github (https://github.com/llccing),或者掘金 (https://juejin.cn/user/3227821867281079),或者语雀 (https://www.yuque.com/uov16w),感谢你的支持!