小编Koj*_*oji的帖子

Angular 中从模板引用属性或 getter 的性能

我有一个关于 Angular 性能的问题。引用公共属性和组件中定义的 getter 之间是否存在性能差异?

示例:
我有一个模板,它引用了isActivate在组件中定义的模板,如下所示:

<div *ngIf="isActivate">Do stuff...</div>
Run Code Online (Sandbox Code Playgroud)

在组件中:

export class TestComponent {
    public isActivate: boolean;
Run Code Online (Sandbox Code Playgroud)

但它可以有一个 getter 来代替:

public get isActivate(): boolean {
    return true;
}
Run Code Online (Sandbox Code Playgroud)

在性能方面,哪个更好,为什么?

angular

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

查询cosmos db中的嵌套数组

具有如下所述的文件列表。

文件1:

 {
    id:1,
    PostList:[
     {
         postname:"aaa",
         lastdatetime:2017-07-13T17:10:25+05:30,
         sname:"sas"
     },
     {
         postname:"aaa1",
         lastdatetime:2017-07-14T17:10:25+05:30,
         sname:"sasadd"
     },
     {
         postname:"aaa2",
         lastdatetime:2017-07-10T17:10:25+05:30,
         sname:"weq"
     }
     ]
}
Run Code Online (Sandbox Code Playgroud)

文件2:

 {
        id:2,
        PostList:[
         {
             postname:"aaa",
             lastdatetime:2017-07-13T17:10:25+05:30,
             sname:"sas"
         },
         {
             postname:"aaa1",
             lastdatetime:2017-07-14T17:10:25+05:30,
             sname:"sasadd"
         },
         {
             postname:"aaa2",
             lastdatetime:2017-07-10T17:10:25+05:30,
             sname:"weq"
         }
         ]
}
Run Code Online (Sandbox Code Playgroud)

我需要一个帖子名称列表,该列表等于“aaa”且 orderby lastdatetime。

我能够得到查询

select f.lastdatetime,f.postname
from c 
join f in c.PostList 
where f.postname='aaa' 
Run Code Online (Sandbox Code Playgroud)

但我需要使用 orderby lastdatetime 获取列表。

当我尝试以下查询时,出现错误

不支持过度相关集合的排序

select f.lastdatetime,f.postname
from c 
join f in c.PostList 
where f.postname='aaa' ORDER BY f.lastdatetime ASC
Run Code Online (Sandbox Code Playgroud)

有人有想法可以通过吗?

azure azure-cosmosdb

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

Angular 2 - 实现UrlSerializer

我正在尝试实现自己的UrlSerializer类,这就是我所做的:

import { UrlSerializer,UrlTree } from '@angular/router';

export class CustomUrlSerializer implements UrlSerializer {

    parse(url: string): UrlTree {
        // Change plus signs to encoded spaces
        url.replace("%20", '-');
        // Use the default serializer that you can import to just do the 
        // default parsing now that you have fixed the url.
        return super.parse(url)  
    }

    serialize(tree: UrlTree): string {
        // Use the default serializer to create a url and replace any spaces with + signs
        return super.serialize(tree).replace("%20", '-');
    }
}
Run Code Online (Sandbox Code Playgroud)

当我尝试编译时,我得到以下错误:

c:/xampp/htdocs/proj/src/app/custom-url-serializer.ts (11,12): …
Run Code Online (Sandbox Code Playgroud)

angular

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

标签 统计

angular ×2

azure ×1

azure-cosmosdb ×1