@angular-material-extensions/select-country

中文文档
17.0.0发布于 2023/11/19MITTypeScriptES Module近 30 天下载 7409

允许用户选择国家或国籍的角材料组件

中文使用文档
文档目录22 节
  1. 由开发者建并供开发者使用 : 心脏 :
  2. 目录
  3. 演示
  4. 图书馆的组成部分
  5. 依赖关系
  6. 安装
  7. 1. 通过 纳克后加 . (建议)
  8. 2. 通过 无 . (备选案文)
  9. 导入库
  10. API 密码
  11. <mat-select-country> 用于显示主组件 - 参见演示示例
  12. 使用量
  13. 选项 1 有反应窗体
  14. 有反应窗体的选项2
  15. 预先定义要装入的国家
  16. 改进业绩----使用 itemsLoadSize 属性
  17. 动态更改语言 - 使用 language 属性
  18. 本地运行 Demo 应用程序
  19. 其他角图书馆
  20. 谁用这个图书馆?
  21. 支助
  22. 许可证

angular-material-extensions's logo

@angular-material-extensions/select-country - 允许用户选择具有自动完成特性的国家或国籍的Angular 材料组件

npm version npm demo docs: typedoc Join the chat at https://gitter.im/angular-material-extensions/Lobby Build Status codecov Greenkeeper Badge license

@angular-material-extensions/select-country demonstration

@angular-material-extensions/select-country demonstration

由开发者建并供开发者使用 : 心脏 :

你有什么问题或建议吗? 请不要犹豫联系我们! 或者,提供PR QQ打开一个适当的问题 这里

如果你喜欢这个项目,请支持 角-材料-扩展 由主演: 明星: 分享它 : 高音:

目录

演示

在 https://angular-material-extension.github.io/select-country 互联网档案馆的存檔,存档日期2014-12-22

图书馆的组成部分

  • <mat-select-country> 用于显示主组件

依赖关系


安装

如果未设置角材料设计, 请运行 ng add @angular/material 学习更多

现在通过 angular schematics

ng add @angular-material-extensions/select-country

2. 通过 无. (备选案文)

安装对等依赖

npm i svg-country-flags -s

然后更新您的 angular.json 类似下面( svg- country- flags)

"assets": [
              "src/favicon.ico",
              "src/assets",
              {
                "glob": "**/*",
                "input": "./node_modules/svg-country-flags/svg",
                "output": "src/assets/svg-country-flags/svg"
              }
            ],

现在安装 @angular-material-extensions/select-country 通过:

npm install --save @angular-material-extensions/select-country

导入库

如果您通过角图安装库, 您可以跳过此步骤

安装后需要导入主模块和 HttpClientModule数字 :

import { MatSelectCountryModule } from "@angular-material-extensions/select-country";
import { MatSelectCountryModule } from '@angular-material-extensions/select-country';
import {HttpClientModule} from '@angular/common/http';

@NgModule({
  declarations: [AppComponent, ...],
  imports: [
              MatSelectCountryModule.forRoot('de'), // you can use 'br' | 'de' | 'en' | 'es' | 'fr' | 'hr' | 'hu' | 'it' | 'nl' | 'pt' --> MatSelectCountrySupportedLanguages
             HttpClientModule, ...],
  bootstrap: [AppComponent]
})
export class AppModule {
}

其他模块

import { MatSelectCountryModule } from '@angular-material-extensions/select-country';
import {HttpClientModule} from '@angular/common/http';

@NgModule({
  declarations: [AppComponent, ...],
  imports: [MatSelectCountryModule, HttpClientModule, ...],
  bootstrap: [AppComponent]
})
export class AppModule {
}

您应用程序中的其他模块, 如懒惰的装入导入 MatSelectCountryModule 输入您的特性模块 :

API 密码

<mat-select-country> 用于显示主组件 - 参见演示示例

选项绑定类型默认说明
价值Input()Country- 说吧选定国家(通过一个空的国家对象,其中包含有alpha2代码以进行alpha2检索)
外观Input()MatFormFieldAppearance- 说吧可能的外观样式 mat-form-field ("legacy","标准","填充"或"外线")
国家Input()Country[]储存在解放区的所有国家应加载的国家 - 预先确定你只需要的国家!
标签Input()boolean- 说吧mat-form-field 标签的文本
记录大小Input()number- 说吧应获取的国家数目 -- > 改善了业绩
车手Input()boolean- 说吧输入占位符文本
已禁用Input()boolean- 说吧组件是否禁用
装入Input()boolean- 说吧组件是否正在装入
无效Input()boolean- 说吧组件是否能够发射 null
只读Input()boolean- 说吧是否只读取组件
选项卡索引Input()number | string- 说吧组件是否可被聚焦, 以及它在哪里参与相继键盘导航
显示呼叫代码Input()boolean虚假在标签和选择中显示国家调用代码的组件
类Input()string- 说吧类属性对输入文本或验证忽略( 可选) 应用样式
语言Input()string- 说吧语言,如果未指定 MatSelectCouncilModule.forRoot ('XX') 将使用(可选)
名称Input()string国家输入元素的属性名称
自动补全Input()string- 说吧输入元素的属性自动完成,以避免一些浏览器提出“ 不” 的建议
选定国家Output()EventEmitter<Country>- 说吧将选定国家发送为对象(见下文界面)
interface Country {
  name: string;
  alpha2Code: string;
  alpha3Code: string;
  numericCode: string;
  callingCode: string;
}

使用量

添加 <mat-select-country> 模板中的元素 :

<mat-select-country>
</mat-select-country>

@angular-material-extensions/select-country demonstration

@angular-material-extensions/select-country demonstration

@angular-material-extensions/select-country demonstration

使用带有反应表单的库

选项 1 有反应窗体

<mat-select-country appearance="outline"
                    label="Country"
                    [formControl]="countryFormControl"
                    (onCountrySelected)="onCountrySelected($event)">
</mat-select-country>

有反应窗体的选项2

<form [formGroup]="countryFormGroup">
    <div fxLayoutAlign="center">
      <mat-select-country appearance="outline"
                          label="Country"
                          class="className"
                          formControlName="country"
                          (onCountrySelected)="onCountrySelected($event)">
      </mat-select-country>
    </div>
  </form>
import {Component,OnInit} from '@angular/core';
import {FormControl} from '@angular/forms';

import {Country} from '@angular-material-extensions/select-country';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})
export class AppComponent implements OnInit{
  title = 'select-country';

  countryFormControl = new FormControl();
  countryFormGroup: FormGroup;

  constructor(private formBuilder: FormBuilder) {
    angulartics2GoogleAnalytics.startTracking();
  }

  ngOnInit(): void {

    this.countryFormGroup = this.formBuilder.group({
      country: []
    });

    this.countryFormGroup.get('country').valueChanges
.subscribe(country => console
.log('this.countryFormGroup.get("country").valueChanges', country));

    this.countryFormControl.valueChanges
.subscribe(country => console
.log('this.countryFormControl.valueChanges', country));
  }


  onCountrySelected($event: Country) {
    console.log($event);
  }
}

预先定义要装入的国家

<mat-select-country appearance="outline"
                    label="Country"
                    [countries]="predefinedCountries"
                    (onCountrySelected)="onCountrySelected($event)">
</mat-select-country>
import {Country} from '@angular-material-extensions/select-country';

predefinedCountries: Country[] = [
  {
    name: 'Germany',
    alpha2Code: 'DE',
    alpha3Code: 'DEU',
    numericCode: '276',
    callingCode: '+49'
  },
  {
    name: 'Greece',
    alpha2Code: 'GR',
    alpha3Code: 'GRC',
    numericCode: '300',
    callingCode: '+30'
  },
  {
    name: 'France',
    alpha2Code: 'FR',
    alpha3Code: 'FRA',
    numericCode: '250',
    callingCode: '+33'
  },
  {
    name: 'Belgium',
    alpha2Code: 'BE',
    alpha3Code: 'BEL',
    numericCode: '056',
    callingCode: '+32'
  }
];

结果 :

@angular-material-extensions/select-country demonstration

改进业绩----使用 itemsLoadSize 属性

<mat-select-country appearance="outline"
                    label="Country"
                    [itemsLoadSize]="5">
</mat-select-country>

只有5个国家会得到!

动态更改语言 - 使用 language 属性

<mat-select-country appearance="outline"
                    label="Country"
                    [language]="languageSelected"
                    (onCountrySelected)="onCountrySelected($event)">
</mat-select-country>

本地运行 Demo 应用程序

构建库

$ npm run build:lib

服务演示程序

$ npm start

其他角图书馆


谁用这个图书馆?

纳豪斯.de - 数字和自动房地产管理

把你的项目放在这里,请放下适当的公关


支助

由开发商建造


jetbrains logo

这个项目得到下列机构的支持: 喷射板 1个产品包 OS License 包括. 网络风暴


许可证

版权(c)2020-2024年 安东尼·纳哈斯获得麻省理工学院许可证

angular-material-extensions's logo

版本与发布记录

@angular-material-extensions/select-country 共发布 41 个版本,首次发布于 2019/11/15;过去 12 个月发布了 0 个版本。

版本发布日期距今
17.0.0latest2023/11/192 年前
16.0.02023/11/192 年前
8.1.02023/01/143 年前
8.0.02022/12/013 年前
7.1.02022/11/183 年前
7.0.12022/07/054 年前

关于 @angular-material-extensions/select-country 的常见问题

@angular-material-extensions/select-country 是什么?

允许用户选择国家或国籍的角材料组件

如何安装 @angular-material-extensions/select-country?

在项目目录运行 npm install @angular-material-extensions/select-country,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@angular/common(^17.x)、@angular/core(^17.x)、@angular/forms(^17.x)、@angular/platform-browser(^17.x)、@angular/cdk(~17.x)、@angular/material(~17.x)、rxjs(^7.x)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@angular-material-extensions/select-country 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@angular-material-extensions/select-country 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@angular-material-extensions/select-country 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=16。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@angular-material-extensions/select-country 可以商用吗?

@angular-material-extensions/select-country 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@angular-material-extensions/select-country 的下载量有多少?

根据 npm 官方下载统计,@angular-material-extensions/select-country 在 2026/10/06 – 2026/11/04 这 30 天内被下载 7,409 次,日均约 247 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@angular-material-extensions/select-country 还在维护吗?

最新版本 17.0.0 发布于 2023/11/19(2 年前);至今共发布 41 个版本,其中过去 12 个月发布了 0 个;首次发布于 2019/11/15。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。