Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/440.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 按角度分页的视图页面_Javascript_Arrays_Angular_Angular5_Angular7 - Fatal编程技术网

Javascript 按角度分页的视图页面

Javascript 按角度分页的视图页面,javascript,arrays,angular,angular5,angular7,Javascript,Arrays,Angular,Angular5,Angular7,我正在尝试使用ngFor将对象数组显示为Word文档视图页面。为此,我准备了一个临时对象,它工作正常,我能够根据内容计数将其显示为页面 var newPageContentLength = 0; var pageNo = 1; var pageObj = { page: `page${pageNo}`, data: [] }; let temp = []; this.contentViewArray = []; temp

我正在尝试使用ngFor将对象数组显示为Word文档视图页面。为此,我准备了一个临时对象,它工作正常,我能够根据内容计数将其显示为页面

  var newPageContentLength = 0;
    var pageNo = 1;
    var pageObj = {
      page: `page${pageNo}`,
      data: []
    };
    let temp = [];
    this.contentViewArray = [];
    temp.forEach((item, i) => {
        newPageContentLength += item.content.length;
      if (i == 0) {
          pageObj.data.push({ ...item, ischecked: true });
        } else {
        if (newPageContentLength < 200) {
            pageObj.data.push({ ...item, ischecked: true });
          } else {
              this.contentViewArray.push({ ...pageObj });
            pageNo += 1;
            pageObj = {
              page: `page${pageNo}`,
              data: [{ ...item, ischecked: true }]
            };
            newPageContentLength = item.content.length;
          }
        }
      if (i == temp.length - 1) {
            this.contentViewArray.push({ ...pageObj });
        }

    });
var newPageContentLength=0;
var pageNo=1;
var pageObj={
页面:`page${pageNo}`,
数据:[]
};
设temp=[];
this.contentViewArray=[];
每小时温度((项目,i)=>{
newPageContentLength+=item.content.length;
如果(i==0){
push({…项,ischecked:true});
}否则{
如果(newPageContentLength<200){
push({…项,ischecked:true});
}否则{
this.contentViewArray.push({…pageObj});
pageNo+=1;
pageObj={
页面:`page${pageNo}`,
数据:[{…项,已检查:true}]
};
newPageContentLength=item.content.length;
}
}
如果(i==温度长度-1){
this.contentViewArray.push({…pageObj});
}
});
使用这种逻辑,如果我的内容长度超过200,我可以创建页码,但问题是,如果对象的内容长度超过200,例如(如果计数为240),我希望下一页中有40个单词

我把这40个字分成了第二页

其他的都很好

stackblitz链接: