我正在尝试将一些数据添加到数组中,但出现不可扩展错误。
组件代码:
this._store.select(p => p.collection.workspaceCollectionPages).subscribe((data: CollectionPageDbModel[]) =>{
if(data){
return data.map((collectionPageDbModel)=> {
this.collectionPages.push(collectionPageDbModel) //Getting error on this line while pushing
});}
Run Code Online (Sandbox Code Playgroud)
我的数据变量中有四个对象,我试图将它们推送到 collectionPages 中,但是在推送时出现可扩展错误。
CollectionPageDbModel:
export class CollectionPageDbModel implements IDbModel {
public id?: number;
public collection_version_id: number;
public user_id?: string;
public name: string;
public position?: number = 0;
public contents: string;
public created_at?: string;
public updated_at?: string;
public server_id?: any;
}
Run Code Online (Sandbox Code Playgroud)
有人可以帮我解决这个问题吗
我有一个json,在这个json里面有一个我要迭代的数组<td>.我的功能就像我必须根据用户输入创建一个表.用户提供行数,输入列和输出列的输入.所以我有三个数组,即$ rootScope.input_columns,$ rootScope.output_columns和$ rootScope.rows,它们包含用户提供的用于创建表的数据.现在在input_columns中有一个数组,其中包含我需要在行单元格上显示的一些信息.但是使用我目前的代码,它给了我空白行.
控制器:
var app = angular.module('rulesApp');
app.controller('myController2', ['$scope', '$rootScope',function($scope, $rootScope){
var inputcol=[];
$rootScope.input_col=$scope.no_of_input;
$rootScope.output_col=$scope.no_of_output;
$rootScope.rows=$scope.no_of_row;
for(var i=0;i<$rootScope.input_col;i++){
inputcol.push({
id: inputcol.length,
dropped: false,
dataType:'',
name:'',
type:'input',
path:'',
rowCellValue:[],
rowCellValueOutput:[]
});
}$rootScope.input_columns=inputcol;//here i get input_columns json, Similarly json are made for output_columns and rows
$scope.statementSelected = function(branch, selected_branches) {
if(branch.selected) {
for(var i = 0; i < $rootScope.input_columns.length; i++) {
//Here i add an array inside input_columns.rowCellValue $rootScope.input_columns[i].rowCellValue.push($rootScope.rows[i].rowCellValue);
}
})
Run Code Online (Sandbox Code Playgroud)
添加input_columns的结构
这是我的HTML代码:
<tbody>
<tr ng-repeat="row in rows"><!--It …Run Code Online (Sandbox Code Playgroud)