小编C. *_*ans的帖子

Angular 2 HTTP进度条

目前Angular 2中有一种方法可以使用angular2/http模块检索ajax调用的进度(即完成百分比)吗?

我使用以下代码进行HTTP调用:

        let body = JSON.stringify(params);
        let headers = new Headers({ 'Content-Type': 'application/json' });
        let options = new RequestOptions({ headers: headers });
        this.http.post(url, body, options)
            .timeout(10000, new Error('Timeout exceeded during login'))
            .toPromise()
            .then((res) => {
                ...
            }).catch((err) => {
                ...
            });
Run Code Online (Sandbox Code Playgroud)

目标是编写同步系统.该帖子将返回大量数据,我想让用户了解同步需要多长时间.

ajax http ionic2 angular

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

ngFor 在删除项目时不更新

我在页面模板(Ionic 2)中使用 *ngFor 。

<div class="child" *ngFor="let child of sharedParams.children">
        ...
</div>
Run Code Online (Sandbox Code Playgroud)

在应用程序内部的某个地方,我会在检测到更改(添加、更新、删除)时更新 children 数组。我这样做是为该属性分配一个新数组:

export class SharedParams {    
    private _children: Child[];

    constructor(children: Child[]){
        this._children = children;
    }

    get children(){
        return this._children;
    }

    set children(children: Child[]){        
        this._children = children;
    }
}
Run Code Online (Sandbox Code Playgroud)

当在数组中添加或更新项目时,会触发 ngFor 并更新 DOM。然而,当一个项目被移除时,数组会改变,但 DOM 不会移除该项目的条目。

我还尝试使用“push”和“splice”手动修改数组而不是替换它。但行为保持名称。当一个项目被移除时,DOM 永远不会更新。

任何帮助将不胜感激。

ionic2 angular

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

在不使用Ember-CLI的情况下向EmberJS 2.0注册帮助程序

我和我的团队正在开发一个使用EmberJS 2.0的应用程序.由于我们有Ember-CLI未提供的特定要求,因此我们使用Grunt任务开发了自己的解决方案来编译我们的应用程序.

使用以前版本的EmberJS,我们使用以下方法注册新的车把助手:

Ember.Handlebars.registerBoundHelper('date-display', function(data, unix) {
    ...
});
Run Code Online (Sandbox Code Playgroud)

我们现在面临的问题是在Ember.Handlebars命名空间中弃用了registerHelper方法.我们现在生成我们的助手:

var dateDisplayHelper = Ember.Helper.helper('date-display', function(params, hash){
     ...
});
Run Code Online (Sandbox Code Playgroud)

我们的问题是,我们如何注册这个帮手,让它在我们的车把模板中可用?

javascript ember.js

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

标签 统计

angular ×2

ionic2 ×2

ajax ×1

ember.js ×1

http ×1

javascript ×1