实现了ag-grid,并定义了一个数据源.
但是没有调用数据源,如何执行数据源
<div class="col-md-12" *ngIf="rowData.length > 0">
<ag-grid-angular #agGrid style="width: 100%; height: 350px;" class="ag-fresh"
[gridOptions]="gridOptions"
[columnDefs]="columnDefs"
[rowData]="rowData"
[datasource] = "dataSource"
enableColResize
enableSorting
enableFilter
rowSelection="single"
></ag-grid-angular>
</div>
Run Code Online (Sandbox Code Playgroud)
import { Component } from '@angular/core';
import { FormGroup, FormControl } from "@angular/forms";
import {GridOptions} from "ag-grid/main";
import {Http, Headers} from '@angular/http';
import * as AppUtils from '../common/app.utils';
@Component({
selector: 'incident-search',
templateUrl: 'app/search/iSearch.component.html'
})
export class ISearchComponent {
myForm: FormGroup;
rowData: Array<IncidentHeaderModel> = new Array<IncidentHeaderModel>();
gridOptions = <GridOptions>{
context: {},
rowModelType: 'pagination', …Run Code Online (Sandbox Code Playgroud) 有一个带有 的表单ag-grid,即使基本网格正在工作,它也会在控制台中出错
除非使用普通行模型,否则不能调用 setRowData
所以大多数 api 函数包括 clear 不起作用。
<form [formGroup]="myForm" (ngSubmit)="search()" >
<button type="submit" class="btn btn-primary ripple">Search</button>
</form>
<div class="grid-wrapper animated fadeIn" >
<ag-grid-angular #agGrid style="width: 100%; height: 315px;" class="ag-fresh"
[gridOptions]="gridOptions"
[columnDefs]="columnDefs"
[rowData]="rowData"
[datasource] = "dataSource"
enableColResize
rowSelection="single"
></ag-grid-angular>
</div>
Run Code Online (Sandbox Code Playgroud)
键入 sript 代码,在构造函数定义的网格和搜索方法中设置从服务器 api 返回的数据。除了用于分页的调用回调方法。
constructor(private masterDataService:MasterDataService,private http: Http) {
this.myForm = new FormGroup({
});
this.gridOptions = <GridOptions>{
context:{},
rowModelType: 'pagination',
paginationPageSize: 10,
// onGridReady: function(event) { this.gridOptions.api.sizeColumnsToFit(); } // this will give error api undefined
}; …Run Code Online (Sandbox Code Playgroud) 如何在angular2中的两个日期之间获得小时差异?我不想使用外部库moment.js.
举例来说:incidentTime ='2017-03-05 11:26:16 AM'和creationTime ='2017-03-06 12:26:16 AM'
let time = +params.data.incidentTime - +params.data.creationTime;
console.log("time: " + time);
Run Code Online (Sandbox Code Playgroud)
它应该返回25小时,但它返回NaN.
有没有一种方法可以检查表单控件是否被禁用?
this.form.get("nationality").disable()
Run Code Online (Sandbox Code Playgroud)
禁用此控件。
我可以检查此控件是否在重置方法中禁用。如果禁用,则不需要重置该值。
我该如何检查。
onReset(){
if(this.form.get("nationality").isDisable()){// its wrong
let name =this.form.get("nationality").value;
}else{
let name = null;
}
this.form.reset({
name: name
});
}
Run Code Online (Sandbox Code Playgroud) 如何禁用模板驱动表单中的所有控件.
试过的解决方案.
使用fieldset并将[disabled]设置为 - 这在IE 9+中不起作用.同样使用fieldset,不会禁用输入
<button class="icon-btn pull-right addNewBtn" type="button" title="Add New " data-toggle="modal" id="Btn" data-backdrop="false"><i (click)="Person(Code)" class="fa fa-user-plus"></i></button>
<p-radioButton name="type" value="I" label="Inc" [(ngModel)]="type"></p-radioButton>
Run Code Online (Sandbox Code Playgroud)
我没有表单组,因此该解决方案在这里也不起作用.
让我知道AngularJS 2中是否还有其他解决方案
我已经从 Spring Boot 1.3.2 T Spring Boot 2.0.2 迁移了 Oauth2 代码。
下面允许“/auth”端点的代码在 springBoot 2 中不起作用
public void configure(HttpSecurity httpSecurity) throws Exception {
httpSecurity
.exceptionHandling()
.authenticationEntryPoint(customAuthenticationEntryPoint)
.and()
.antMatchers("/auth/**").permitAll()
.anyRequest()
.authenticated();
}
Run Code Online (Sandbox Code Playgroud)
/auth 端点返回 401 响应。
经过研究,我已经添加了
.anonymous().and()
它现在按预期工作。/auth 返回没有令牌的结果。
我无法弄清楚原因,spring boot 2 发生了什么变化。?
在将rx js从5升级到6时,抛出低于错误
[ts]'BehaviorSubject'类型中不存在属性'过滤器'.
当前行为
import {BehaviorSubject} from 'rxjs';
tokenSubject: BehaviorSubject<string> = new BehaviorSubject<string>(null);
return this.tokenSubject
.filter(token => token != null)
.take(1)
.switchMap(token => {
return next.handle(this.addToken(req));
});
Run Code Online (Sandbox Code Playgroud)
[ts]'BehaviorSubject'类型中不存在属性'过滤器'.
环境
"@angular/common": "^6.0.3",
"rxjs": "^6.0.0",
Run Code Online (Sandbox Code Playgroud)
预期的行为
没有错误,工作正常
以前的行为
import { BehaviorSubject } from "rxjs/BehaviorSubject";
tokenSubject: BehaviorSubject<string> = new BehaviorSubject<string>(null);
return this.tokenSubject
.filter(token => token != null)
.take(1)
.switchMap(token => {
return next.handle(this.addToken(req));
});
Run Code Online (Sandbox Code Playgroud)
[ts]'BehaviorSubject'类型中不存在属性'过滤器'.
环境
"@angular/common": "^5.0.3",
"rxjs": "^5.4.3"
Run Code Online (Sandbox Code Playgroud) 我想从字符串中替换所有空格,但我需要保留新的行字符吗?
choiceText=choiceText.replace(/\s/g,'');
india
aus //both are in differnt line
Run Code Online (Sandbox Code Playgroud)
正在给予 indaus
我想换行应该保留并删除s
使用过滤器生成了一个json数组.
orders = filterFilter(vm.gridOptions.data, {
sampleId: 295
});
Run Code Online (Sandbox Code Playgroud)
在这里我过滤了我的订单数组,我得到了这个.
{
"orders": [
{
"orderId": 51491,
"orderDate": "2016-12-19T13:35:39",
"regId": 1354,
"sampleId": 295,
"name": "Test",
"nameAr": "Test"
},
{
"orderId": 51493,
"orderDate": "2016-12-19T13:35:39",
"regId": 1354,
"sampleId": 295,
"name": "Test",
"nameAr": "Test",
}
]
}
Run Code Online (Sandbox Code Playgroud)
我可以过滤,它应该只在orders数组中保留一个字段.使用角度滤波器我需要这样做.
我需要一个像这样的数组.
{
"orders": [
{
"orderId": 51491
},
{
"orderId": 51493
}
]
}
Run Code Online (Sandbox Code Playgroud) Spring 验证返回长错误消息而不是自定义一次。
这是 dto 中的代码部分。
public class RequestDto implements Serializable {
@NotNull(message="{id.required}")
private Long id;
}
Run Code Online (Sandbox Code Playgroud)
在控制器中为输入添加了@Valid。
@RequestMapping(value = ApiPath.PATH, method = RequestMethod.POST, produces = { "application/xml",
"application/json" })
public @ResponseBody ResultDecorator saveRequest(
@Valid @RequestBody RequestDto msaDisabScreenRequestDto) throws Exception {
}
Run Code Online (Sandbox Code Playgroud)
API 返回以下错误。
<message>Validation failed for argument at index 0 in method: public om.gov.moh.msa.framework.resolver.ResultDecorator om.controller.MaController.saveRequest(om..dto.RequestDto) throws java.lang.Exception, with 1 error(s): [Field error in object 'requestDto' on field 'id': rejected value [null]; codes [NotNull.requestDto.id,NotNull.id,NotNull.java.lang.Long,NotNull]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [requestDto.id,id]; arguments []; default …Run Code Online (Sandbox Code Playgroud) 这是父组件。添加了一个子组件并传递了表单。这里同时使用表单控件名称和 NgModel(这是最佳实践吗)。加载页面控制台时出现错误“ngModel 无法用于向父 formGroup 指令注册表单控件。”
<div class="inner-wrapper">
<form [formGroup]="form">
<pat-demo-information [group]="form"></pat-demo-information>
<div class="panel-body">
<div class="row">
<div class="col-lg-2 col-md-3 col-sm-3">
<div class="ui-input-group">
<input type="text" maxlength="15" class="form-control" [(ngModel)]="notif.en.No" formControlName="epiNo">
<span class="input-bar"></span>
<label>No.</label>
</div>
</div>
</div>
</div>
</div>
</form>
</div>
Run Code Online (Sandbox Code Playgroud)
这是子组件
@Component({
selector: 'patient-demographic-information',
templateUrl: './pat-demo-information'
})
export class PatDemoInfoComponent implements OnInit {
@Input() patientForm: FormGroup
noti: MaltreatmentNoti;
instid: number;
instPatientid: number;
latitude: number;
longitude: number;
enMpi: Mpi = new Mpi();
constructor(private formBuilder: FormBuilder) {
}
ngOnInit() {
this.notification = new MaltreatmentNoti();
this.notification.enMpi …Run Code Online (Sandbox Code Playgroud) angular ×5
typescript ×4
ag-grid ×2
spring-boot ×2
angular6 ×1
angular7 ×1
angular8 ×1
angularjs ×1
date ×1
javascript ×1
oauth ×1
oauth-2.0 ×1
regex ×1
rxjs ×1
rxjs6 ×1