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
-
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 文件中已经针对该类型进行了处理: /**
* Takes a string or an `Observable` that emits strings.
* Overrides the value provided by the `I18n` service.
*/
override(value: string | Observable<string>) {
this.isOverridden = true;
// To ensure that there are not multiple subscriptions created for the same observable, we
// unsubscribe if a subscription already exists for an observable before creating a new one.
if (this.subscription) {
this.subscription.unsubscribe();
this.subscription = null;
}
this._value = value;
// 这里判断了 value 的类型后做处理。
if (isObservable(value)) {
this.subscription = value.subscribe(v => {
this.$override.next(v);
});
} else {
this.$override.next(value);
}
}
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),感谢你的支持!
-