我的一个组件中有这个:
\npublic booleanSubject: BehaviorSubject<boolean> = new BehaviorSubject(false);\nRun Code Online (Sandbox Code Playgroud)\n当我添加"strictFunctionTypes": true到tsconfig.json文件时,出现以下错误:
\xc3\x97 Compiling TypeScript sources through NGC\nERROR: path/to/my/component.component.ts:28:10 - error TS2322: Type \'BehaviorSubject<false>\' is not assignable to type \'BehaviorSubject<boolean>\'.\n Types of property \'observers\' are incompatible.\n Type \'Observer<false>[]\' is not assignable to type \'Observer<boolean>[]\'.\n Type \'Observer<false>\' is not assignable to type \'Observer<boolean>\'.\n Type \'boolean\' is not assignable to type \'false\'.\n\n28 public booleanSubject: BehaviorSubject<boolean> = new BehaviorSubject(false);\nRun Code Online (Sandbox Code Playgroud)\n有谁知道原因以及如何通过将标志设置为不抛出strictFunctionTypes错误true?
我有一个带分页的数据网格.当我更改页面时,我想更新页面中的某些组件,但我不知道如何获取该事件.一些代码:
<p:panelGrid id="buttons">
<p:commandLink value="Link1" action="#{myBean.method1}" disabled="#{myBean.boolean1}" />
<p:commandLink value="Link2" action="#{myBean.method2}" disabled="#{myBean.boolean2}" />
</p:panelGrid>
<p:dataGrid var="myVar" paginator="true" value="#{myBean.listOfObjects}">
...
...
</p:dataGrid>
Run Code Online (Sandbox Code Playgroud)
我想要一些类似于update="buttons"dataGrid的东西,所以当页面改变时,根据按钮的disabled=""属性更新按钮,是否可能?
问候.
这是关于编程最佳实践的问题,我不知道如何在标题中表达问题,对不起,我们走了.
我通过这种方式在Manager或Controller中有一个方法:
public boolean myMethod(Param1 param1);
Run Code Online (Sandbox Code Playgroud)
并且,因为应用程序的更改,我必须像这样重新定义它,因为它调用其他需要param2和param3的方法:
public boolean myMethod(Param1 param1, Param2 param2, Param3 param3);
Run Code Online (Sandbox Code Playgroud)
现在我认识到,与3个PARAMS方法"永远"(现在,也许在未来有变化,我需要与非空PARAMS来称呼它)将被用param2=null和param3=null,所以在第一个方法的实现我做:
public boolean myMethod(Param1 param1) {
return this.myMethod(param1, null, null);
}
public boolean myMethod(Param1 param1, Param2 param2, Param3 param3) {
/* Call to other methods that is needed to pass it param2 and param3 */
}
Run Code Online (Sandbox Code Playgroud)
因此,调用Manager的方法和原始方式是:
boolean isTrue = myManager.myMethod(param1);
Run Code Online (Sandbox Code Playgroud)
这是一个选项,另一个选项是从调用中传递null参数:
boolean isTrue = myManager.myMethod(param1, null, null);
Run Code Online (Sandbox Code Playgroud)
在我的经理中只允许使用一种方法:
public boolean myMethod(Param1 param1, Param2 param2, Param3 param3);
Run Code Online (Sandbox Code Playgroud)
所以,真正的问题是:谈论最佳实践的最佳方法是什么?如果在管理器的实现中我重载一个方法并使用null参数调用它是错误的吗?
提前致谢!
问候.
我正在尝试index.html使用html5Mode(true)angularjs 删除url ,这是代码:
angular.module('myApp', [
'ngRoute',
'myApp.filters',
'myApp.services',
'myApp.directives',
'myApp.controllers'
]).
config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) {
$locationProvider.html5Mode(true);
$routeProvider.when('/home', {templateUrl: 'views/home.html'});
$routeProvider.when('/about', {templateUrl: 'views/about.html'});
$routeProvider.otherwise({redirectTo: '/'});
}]);
Run Code Online (Sandbox Code Playgroud)
如果我不写$locationProvider.html5Mode(true);网址显示:
本地主机:(端口)/MyApplication/index.html
如果我写$locationProvider.html5Mode(true);的网址显示:
本地主机:(端口)
MyApplication删除了网址.我想要网址显示:
本地主机:(端口)/所有MyApplication /
我做错了什么?有什么问题?
更新:
应该如何显示我的<a>标签?现在我有:
<a href="#/about">About</>
Run Code Online (Sandbox Code Playgroud)
当我点击链接时,网址显示:
本地主机:(端口)/MyApplication/index.html#/about
我迷失了.
提前致谢!
我通过VirtualBox从Windows 7连接到Ubuntu 14.04 LTS,然后从Ubuntu通过Remmina连接到Windows Server 2012.
我已经将Remmina配置为连接共享文件夹但我不知道如何在Windows Server 2012中看到该共享文件夹,可能添加了网络位置,但是当我被问到网络地址时我不知道我在做什么不得不写.
这种方式是否正确?我错过了什么?
我创建了一个拦截器来在发出 HTTP 请求时显示旋转器:
import { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { NgxSpinnerService } from 'ngx-spinner';
import { Observable } from 'rxjs/Observable';
import { finalize } from 'rxjs/operators';
@Injectable()
export class SpinnerInterceptor implements HttpInterceptor {
constructor(
private spinner: NgxSpinnerService
) { }
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
this.spinner.show();
return next.handle(req).pipe(finalize(() => this.spinner.hide()));
}
}
Run Code Online (Sandbox Code Playgroud)
我正在使用ngx-spinner来达到这个目的。
例如,我只想仅针对耗时超过 1 秒的 HTTP 请求显示微调器。我一直在尝试使用debounceTime但我不确定如何使用它或者它是否适合我想要的。
有没有办法使用拦截器来做到这一点?
更新:我在打开问题后找到了解决方案,它与@joyBlanks 答案非常相似,这就是我所做的:
intercept(req: HttpRequest<any>, next: HttpHandler): …Run Code Online (Sandbox Code Playgroud) 我有一个日历:
<p:calendar id="fechaInicio" mode="inline"
value="#{informesBean.fechaInicio.fecha}"
pattern="#{informesBean.fechaInicio.pattern}">
<p:ajax event="dateSelect" listener="#{informesBean.limpiaLink}"
update="link" />
</p:calendar>
Run Code Online (Sandbox Code Playgroud)
这是我limpiaLink的informesBean:
public void limpiaLink(SelectEvent event) {
Date date = (Date) event.getObject();
extraido = false;
System.out.print(date.toString());
}
Run Code Online (Sandbox Code Playgroud)
我有一个断点
日期日期=(日期)event.getObject();
但永远不要停留在我的断点,我做错了什么?
编辑:使用Inspect Element of Chrome我刚刚意识到当我点击我日历的一天时,Chrome会抛出这个:
POST http://localhost:8080/quickpacity/pages/planificacion/informeTestManager.xhtml 500 (Error Interno del Servidor) jquery.js.xhtml:21
send jquery.js.xhtml:21
bG.extend.ajax jquery.js.xhtml:21
PrimeFaces.ajax.AjaxUtils.send primefaces.js.xhtml:1
PrimeFaces.ajax.Queue.offer primefaces.js.xhtml:1
PrimeFaces.ajax.AjaxRequest primefaces.js.xhtml:1
PrimeFaces.ab primefaces.js.xhtml:1
PrimeFaces.cw.behaviors.dateSelect informeTestManager.xhtml:34
PrimeFaces.widget.Calendar.PrimeFaces.widget.BaseWidget.extend.fireDateSelectEvent primefaces.js.xhtml:6
cfg.onSelect primefaces.js.xhtml:6
$.extend._selectDate jquery-plugins.js.xhtml:147
$.datepicker._selectDate jquery-plugins.js.xhtml:340
$.extend._selectDay jquery-plugins.js.xhtml:147
handler.selectDay jquery-plugins.js.xhtml:147
bG.event.dispatch jquery.js.xhtml:14
b6.handle.b4
Run Code Online (Sandbox Code Playgroud) 我刚刚将一个应用程序模块迁移为一个可导入的库。
我试图让测试正常工作,就像他们以前一样,但我收到了这个错误:
Error: Can't resolve all parameters for ApplicationModule: (?).
at syntaxError (webpack:///C:/Repositories/MyProject/my-library/node_modules/@angular/compiler/fesm5/compiler.js?:1275:17)
at CompileMetadataResolver._getDependenciesMetadata (webpack:///C:/Repositories/MyProject/my-library/node_modules/@angular/compiler/fesm5/compiler.js?:11176:35)
at CompileMetadataResolver._getTypeMetadata (webpack:///C:/Repositories/MyProject/my-library/node_modules/@angular/compiler/fesm5/compiler.js?:11069:26)
at CompileMetadataResolver.getNgModuleMetadata (webpack:///C:/Repositories/MyProject/my-library/node_modules/@angular/compiler/fesm5/compiler.js?:10937:24)
at CompileMetadataResolver.getNgModuleSummary (webpack:///C:/Repositories/MyProject/my-library/node_modules/@angular/compiler/fesm5/compiler.js?:10747:35)
at eval (webpack:///C:/Repositories/MyProject/my-library/node_modules/@angular/compiler/fesm5/compiler.js?:10861:51)
at Array.forEach (<anonymous>)
at CompileMetadataResolver.getNgModuleMetadata (webpack:///C:/Repositories/MyProject/my-library/node_modules/@angular/compiler/fesm5/compiler.js?:10849:49)
at CompileMetadataResolver.getNgModuleSummary (webpack:///C:/Repositories/MyProject/my-library/node_modules/@angular/compiler/fesm5/compiler.js?:10747:35)
at eval (webpack:///C:/Repositories/MyProject/my-library/node_modules/@angular/compiler/fesm5/compiler.js?:10861:51)
Run Code Online (Sandbox Code Playgroud)
我已经看到了这些可能的解决方案: 错误:无法解析 ApplicationModule 的所有参数:(?)和无法解析 ApplicationModule 的参数:(?)但它们无法解决我的问题。
项目/我的图书馆/src/test.ts
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
import { getTestBed } from '@angular/core/testing';
import {
BrowserDynamicTestingModule,
platformBrowserDynamicTesting
} from '@angular/platform-browser-dynamic/testing';
import …Run Code Online (Sandbox Code Playgroud) 它看起来很容易,但我无法做到.我想在点击登录按钮后更改视图,这是我的代码:
app.js
Ext.require ('Ext.container.Viewport');
Ext.application({
name: 'MyApp',
appFolder: 'app',
views: [
'Login',
'Main'
],
controllers:[
'Login'
],
launch: function() {
Ext.create('Ext.container.Viewport', {
layout: 'fit',
items: [{
xtype: 'loginView'
}]
});
}
});
Run Code Online (Sandbox Code Playgroud)
Login.js(查看)
Ext.define('MyApp.view.Login' ,{
extend: 'Ext.panel.Panel',
alias : 'widget.loginView',
title: 'MyApp',
layout: {
type: 'hbox',
pack: 'center',
padding: 50
},
defaults: {
border: false,
width: 400,
height: 400
},
items: [{
xtype: 'panel',
html: '<img src="resources/img/img.jpg" />'
}, {
xtype: 'loginForm'
}]
});
Ext.define('MyApp.view.LoginForm', {
extend: 'Ext.form.Panel',
alias: 'widget.loginForm', …Run Code Online (Sandbox Code Playgroud) 我有一个分页的数据表,我想用数据表外的命令链接更改当前页面,我怎么能得到它?
<p:commandLink title="changePage" action="#{myBean.changeMethod}"
update="myDataTable" />
<p:dataTable id="myDataTable" var="myItem" paginator="true" rows="1"
value="#{myBean.ListOfItem}" binding="#{myBean.DataTable}">
...
...
</p:dataTable>
Run Code Online (Sandbox Code Playgroud)
问候!
angular ×3
jsf-2 ×3
primefaces ×3
ajax ×2
angularjs ×1
calendar ×1
commandlink ×1
datagrid ×1
datatable ×1
date ×1
extjs ×1
html5 ×1
interceptor ×1
java ×1
javascript ×1
pagination ×1
spinner ×1
testing ×1
tsconfig ×1
typescript ×1
ubuntu ×1
url ×1
view ×1