如何在angular4中创建像angularjs这样的对象
How to create object like angularjs in angular4
我正在使用新的 angular 4 来学习和创建项目,但我需要帮助来创建像 anglarjs 这样的对象 $scope.Param = {}; $scope.Param.MyId = "2231dddd";
如何在 angular4 和 post 数据中执行此操作,请查看以下代码
export class HomeComponent {
public forecasts: WeatherForecast[];
public EntityTypeList: EntityTypeList[];
public Param: { id: string; };
CreateDb() {
this.Param.id = this.selectedValue;
this.http.post('http://localhost:1101/api/db/CreateDb', this.Param).subscribe(result => {
}, error => console.error(error));
}
}
然后您可以这样声明 属性
public Param : any = {};
或者如果你的参数对象是字符串的键值对,你可以使用:
public param: {[key: string]: string};
我正在使用新的 angular 4 来学习和创建项目,但我需要帮助来创建像 anglarjs 这样的对象 $scope.Param = {}; $scope.Param.MyId = "2231dddd";
如何在 angular4 和 post 数据中执行此操作,请查看以下代码
export class HomeComponent {
public forecasts: WeatherForecast[];
public EntityTypeList: EntityTypeList[];
public Param: { id: string; };
CreateDb() {
this.Param.id = this.selectedValue;
this.http.post('http://localhost:1101/api/db/CreateDb', this.Param).subscribe(result => {
}, error => console.error(error));
}
}
然后您可以这样声明 属性
public Param : any = {};
或者如果你的参数对象是字符串的键值对,你可以使用:
public param: {[key: string]: string};