在以前的版本中,可以使用.angular-cli.json禁用spec.ts,如下所示.有什么办法在版本6.0.0中使用angular.json吗?
"defaults": {
"component": {
"spec": false
},
"service": {
"spec": false
},
...
}
Run Code Online (Sandbox Code Playgroud) 我有一些看起来像这样的数据:
在我身上app.component.html我有这个:
<ul>
<li *ngFor="let data of myData">{{data.id}}</li>
</ul>
Run Code Online (Sandbox Code Playgroud)
当我运行它时它显示列表但没有任何值,所以我只是从中得到了很多点 <li>
在我的app.component.ts身上:
myData;
Run Code Online (Sandbox Code Playgroud)
然后:
this.myData = obj; // Obj contains the data
Run Code Online (Sandbox Code Playgroud)
我怎样才能解决这个问题?
我试图通过遵循此链接来创建角度为6的通用应用程序。完成链接中提到的步骤后,我尝试构建通用应用程序,但显示以下错误。
Project 'testapp' could not be found in workspace.
Error: Project 'testapp' could not be found in workspace.
Run Code Online (Sandbox Code Playgroud)
谁能帮我解决这个问题?
我正在使用新语法来遵守RxJS 6 pipe()。同样使用Angular6。我有一个处理http请求的服务,它通过管道catchError传输地图并在出现连接错误时显示祝酒词。不过,如果我添加,catchError我会进入控制台,您在期望流的位置提供了“ undefined”。您可以提供一个Observable,Promise,Array或Iterable。
getDataHttpRequest(url, returnType) {
return this.http.get(url, this.getRequestOptions())
.pipe(
map((response) => {
if(response){
if (returnType === 'object') {
return response[0] == undefined ? response : response[0];
} else {
return response;
}
}
}),
catchError((error):any => {
if(error instanceof HttpErrorResponse && error.status === 0){
//no connection error(either user has no connection or the server is down)
this.toastr.error('Chequee su conexión e intente de nuevo en unos momentos. Contáctenos para reportar el problema a …Run Code Online (Sandbox Code Playgroud) 以下是我的代码,可从服务获得响应。在这里,我得到了员工名单。
我需要根据服务的响应动态地绑定表单控件,我的服务返回的字段(表单中的员工ID,姓名,部门等)比表单控件更多。如何跳过那些不在窗体控件中使用的控件?
this._employeeService.getEmployeeById(this.employeeId).subscribe((res: Response) => {
debugger;
this.employeeForm.get('FileUploader').setValue(null);
//this.employeeForm.setValue(res);
for (const field in res) {
this.employeeForm.controls[field].setValue(res[field]);
}
});
this.employeeForm = this._fb.group({
EmployeeId: 0,
Name: ''});
Run Code Online (Sandbox Code Playgroud) In e2e test I want to have environment variable similar to the one as in Angular app. Looks like e2e test project builder "builder": "@angular-devkit/build-angular:protractor" does not support file replacements (unlike builder for web app):
"fileReplacements": [{
"replace": "apps/web/src/environments/environment.ts",
"with": "apps/web/src/environments/environment.prod.ts"
}]
Run Code Online (Sandbox Code Playgroud)
So using Angular CLI ng e2e command I can switch configurations (or projects in angular.json) and in project configuration I can specify different Protractor configuration files protractor.conf.js. My question is: how can I get in e2e test …
我在Angular 6应用程序中使用的是“ AG Grid”社区版。
我现在面临的挑战是:我有一个相当简单的数据结构,其中的一个列表绑定到网格上进行显示。基于其值,我想在网格中添加“操作”列,以使用户可以访问某些操作,例如删除条目,“升级”它等。
对于单独的数据绑定列,当绑定时,我会获得每一行的相应数据值,例如,可以使用单元格渲染器格式化显示。我希望能够与“动作”列(未绑定到该类的特定数据元素)做类似的事情-但看来我的“动作单元格渲染器”没有任何基础它的决定。
我有一个像这样的数据结构:
export interface Indicator {
Id: string;
Name: string;
IsGlobal: boolean;
}
Run Code Online (Sandbox Code Playgroud)
这些数组Indicators被绑定到OnInit我的Angular组件的功能中的AG网格。
我将AG网格的列定义为:
columnDefs = [
{ headerName: 'Name', field: 'Name', width: 200, editable: true },
{ headerName: 'Global', field: 'IsGlobal', editable: false, width: 100,
cellRenderer: (data) => {
// here, "data" refers to the "IsGlobal" value of the row being displayed
if (data.value === true) {
return 'Ja';
} else {
return 'Nein';
}
},
}, …Run Code Online (Sandbox Code Playgroud) 所以我想导航到特定路线后重新加载应用程序。
我使用router.navigate根据用户角色导航到某些路由,效果很好,但是如果来自登录页面(并非每次用户打开该特定路由),我必须在路由后重新加载页面-此处重新加载是为了更新页面语言取决于用户的语言
所以我想做的是
else if(this.sp.role === 'Admin') {
console.log('ooo')
this.router.navigate(['/admin/dashboard']);
this.window.location.reload();
Run Code Online (Sandbox Code Playgroud)
但这会重新加载登录页面
我尝试通过运行以下命令将7号角降级为6npm号角:
npm uninstall -g angular-cli
npm cache clean
npm install -g angular-cli@6.1.1
Run Code Online (Sandbox Code Playgroud)
但是,我的文件中仍显示angular/cli 7版本package.json。我需要帮助以降级angular7为angular6。
数组:
array1 = [{id:1, name:"raju"},{id:2, name:"ravi"},{id:4, name:"john"},{id:6, name:"jack"}];
array2= [{id:1, degree:"b.com"},{id:3, degree:"b.a"},{id:4, degree:"c.a"},{id:5, degree:"horticulture"}];
array3= [{id:1, age:20},{id:3, age:21},{id:6, age:27},{id:7, age:25}];
Run Code Online (Sandbox Code Playgroud)
所需结果是:
resultarray = [
{id:1, name: "raju", degree:"b.com",age:20},
{id:2, name: "ravi"},
{id:3, degree:"b.a", age:21},
{id:4, name:"john", degree:"c.a"},
{id:5, degree:"horticulture"},
{id:6, name:"jack", age:27},
{id:7, age:25}
]
Run Code Online (Sandbox Code Playgroud)
我尝试了不同的功能,并尝试了两个数组,但无法合并没有ID进行比较的对象。
angular6 ×10
angular ×5
typescript ×4
ag-grid ×1
angular-cli ×1
angular5 ×1
angular7 ×1
e2e-testing ×1
javascript ×1
npm ×1
protractor ×1
routing ×1
rxjs ×1
rxjs6 ×1