小编Jay*_*ase的帖子

订阅Angular 2中的route params和queryParams

我已经设置了以下路由系统

export const MyRoutes: Routes = [
    {path: '', redirectTo: 'new', pathMatch: 'full'},
    {path: ':type', component: MyComponent}
];
Run Code Online (Sandbox Code Playgroud)

并有以下导航系统

goToPage('new');
goToPageNo('new', 2);

goToPage(type) {
    this.router.navigate([type]);
}
goToPageNo(type, pageNo) {
    this.router.navigate([type], {queryParams: {page: pageNo}});
}
Run Code Online (Sandbox Code Playgroud)

示例网址如下所示

HTTP://本地主机:3000 /新

HTTP://本地主机:3000 /新页= 2

HTTP://本地主机:3000 /更新

HTTP://本地主机:3000 /更新的页面= 5

有时他们有可选的 queryParams(页面)

现在我需要读取route params和queryParams

ngOnInit(): void {
    this.paramsSubscription = this.route.params.subscribe((param: any) => {
        this.type = param['type'];
        this.querySubscription = this.route.queryParams.subscribe((queryParam: any) => {
            this.page = queryParam['page'];
            if (this.page)
                this.goToPageNo(this.type, …
Run Code Online (Sandbox Code Playgroud)

rxjs angular

25
推荐指数
6
解决办法
2万
查看次数

什么是数据绑定属性?

我试图理解angular2中的OnInit功能并阅读文档:

描述

在初始化指令的数据绑定属性后,实现此接口以执行自定义初始化逻辑.

在第一次检查指令的数据绑定属性之后,以及在检查其任何子项之前,立即调用ngOnInit.实例化指令时仅调用一次.

我不明白directive's data-bound properties这是什么意思?

angular

17
推荐指数
1
解决办法
6460
查看次数

输入“表单组| null' 不可分配给类型'FormGroup'。类型“null”不可分配给类型“FormGroup”。角11

我是 Angular 新手,我使用版本 11。并且我的 html 文件中的 formGroup 属性有问题。

错误 :

'表格组| null' 不可分配给类型'FormGroup'。类型“null”不可分配给类型“FormGroup”。

2 <form [formGroup]="produitFormGroup">

我的html代码。

 <form [formGroup]="produitFormGroup">
    <div class="form-group">
        <label>Nom</label>
        <input type="text" class="form-control" formControlName="name">
    </div>
    <div class="form-group">
        <label>Prix</label>
        <input type="text" class="form-control" formControlName="price">
    </div>
    <div class="form-group">
        <label>Quantite</label>
        <input type="text" class="form-control" formControlName="quantity">
    </div>
    <div class="form-group">
        <label>Selected</label>
        <input type="checkbox" formControlName="selected">
    </div>
    <div class="form-group">
        <label>Available</label>
        <input type="checkbox" formControlName="available">
    </div>
    <button class="btn btn-success">Enregistrer</button>
</form>
Run Code Online (Sandbox Code Playgroud)

我的 ts 文件代码:

produitFormGroup: FormGroup | null= null;

constructor(private fb: FormBuilder) { }

ngOnInit(): void {

   this.produitFormGroup = this.fb.group({ …
Run Code Online (Sandbox Code Playgroud)

html api angular angular-reactive-forms

15
推荐指数
3
解决办法
4万
查看次数

在angular2中设置无效的无效表单控件

是否可以在angular2中设置为无效的表单控件?(用过的表单构建器)

例如.我有form-> exampleFrom&field-> exampleControl

我试过这个,没有成功:

this.exampleFrom.controls['exampleControl'].invalid 
Run Code Online (Sandbox Code Playgroud)

angular angular-reactive-forms

7
推荐指数
1
解决办法
1万
查看次数

Angular 2:在某些条件下应用Validator.required验证

我有一个有角度的2形式,其中我必须在某些条件下需要一个字段,如:

description:  ['', Validators.required]
Run Code Online (Sandbox Code Playgroud)

仅在某些类型的条件下才需要此描述字段,例如:

if(true){descReq = true};
Run Code Online (Sandbox Code Playgroud)

我怎么能做到这一点,请建议.提前致谢!

angular2-forms angular angular-reactive-forms angular-forms

6
推荐指数
2
解决办法
2059
查看次数

Node + Angular Universal SSR:渲染页面时如何设置设备宽度

我正在寻找一种使用 Angular Universal 为服务器端渲染设置设备宽度的方法,以便我控制预渲染页面是移动布局还是桌面布局。

我正在使用核心 ngExpressEngine 进行渲染(与通用 starter几乎相同)。

    const {AppServerModuleNgFactory, LAZY_MODULE_MAP} = require('./dist/server/main.bundle');

    app.engine('html', ngExpressEngine({
      bootstrap: AppServerModuleNgFactory,
      providers: [
        provideModuleMap(LAZY_MODULE_MAP)
      ]
    }));
Run Code Online (Sandbox Code Playgroud)

angular-universal angular angular5

5
推荐指数
1
解决办法
1329
查看次数

具有 V2 身份验证的 Azure Function 的 ARM 模板

我一直在使用 ARM 模板来部署 Azure Function,并使用 V1 身份验证进行 Azure Ad b2c 身份验证。

    "resources": [{
        "name": "[concat(parameters('appName'), '/authsettings')]",
        "apiVersion": "2016-08-01",
        "type": "Microsoft.Web/sites/config",
        "location": "[resourceGroup().location]",
        "dependsOn": [
          "[resourceId('Microsoft.Web/sites', parameters('appName'))]"
        ],
        "properties": {
          "enabled": true,
          "unauthenticatedClientAction": "RedirectToLoginPage",
          "tokenStoreEnabled": true,
          "clientSecret":"[parameters('b2cClientSecret')]",
          "clientId": "[parameters('b2cClientId')]",
          "issuer": "[parameters('b2cMetadataDocumentUrl')]"
        }
      }] 
Run Code Online (Sandbox Code Playgroud)

一切都工作正常,直到我开始收到从Azure 门户中的经典身份验证体验升级的消息。

在此输入图像描述

收到此消息后,部署失败并显示以下消息

##[error]At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/DeployOperations for usage details.
##[error]Details:
##[error]undefined: Cannot execute the request for site app-fun-my-af because the site is running on …
Run Code Online (Sandbox Code Playgroud)

azure azure-resource-manager azure-ad-b2c azure-rm-template azure-functions

1
推荐指数
1
解决办法
1731
查看次数