我有一个Angular 5应用程序,我希望使用最新的Angular模板RC在ASP.net Core上使用Angular Universal .我已经按照文档操作并启动并运行了应用程序.问题是我也在使用Angular的i18n工具,它生成多个编译的应用程序,每个语言环境1个.我需要能够主持每一个https://myhost.com/{locale}/.
我知道我可以为每个区域设置启动ASP.net核心应用程序的实例,并在网络服务器中设置托管以使相应的路径路由到关联的应用程序,但这对我来说似乎过分了.
路由配置为:
// app is an instance of Microsoft.AspNetCore.Builder.IApplicationBuilder
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller}/{action=Index}/{id?}");
});
Run Code Online (Sandbox Code Playgroud)
SpaServices配置有:
app.UseSpa(spa =>
{
// To learn more about options for serving an Angular SPA from ASP.NET Core,
// see https://go.microsoft.com/fwlink/?linkid=864501
spa.Options.SourcePath = "ClientApp";
spa.UseSpaPrerendering(options =>
{
options.BootModulePath = $"{spa.Options.SourcePath}/dist-server/main.bundle.js";
options.BootModuleBuilder = env.IsDevelopment()
? new AngularCliBuilder(npmScript: "build:ssr:en")
: null;
options.ExcludeUrls = new[] { "/sockjs-node" };
options.SupplyData = (context, data) =>
{ …Run Code Online (Sandbox Code Playgroud) 我需要能够使用代码翻译的字符串在我的角度应用程序,但对国际化工具还没有完成这一任务,我实现了一个稍微哈克版本,它利用的角度现有的国际化能力,以逐步淘汰的意图我原生Angular的解决方案,因为它的i18n功能可以满足我的需求(应该是5.x版本,手指交叉).
基本上,我有一个TranslationDirective从DOM读取文本,并在文本更改时发出事件:
@Directive({
selector: '[myAppTranslation]'
})
export class TranslationDirective implements AfterViewChecked, OnChanges {
/**
* dependencies takes an array of the values needed to calculate the output translation
* we use this for change detection, to minimize the DOM interaction to only when it is necessary
*/
@Input() dependencies: any[];
isDirty = true;
@Input() messageKey: string;
message: string;
@Output() messageUpdated = new EventEmitter<TranslationEvent>();
constructor(public el: ElementRef) {}
/**
* sets the translated message and triggers the …Run Code Online (Sandbox Code Playgroud) 我正在尝试制作一个谷歌图表仪表板并尝试以下代码:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>
Google Visualization API Sample
</title>
<script type="text/javascript" src="//www.google.com/jsapi"></script>
<script type="text/javascript">
google.load('visualization', '1.1', {packages: ['controls']});
</script>
<script type="text/javascript">
function drawVisualization() {
var listOfValues = document.getElementById("id1").value ;
var temp2 = null;
var temp3 = null ;
var longArray = ['Year','Positive','Negative','Neutral','Comments','Status','Score'];
var shortArrays = [], m, len;
var arrayOfArray = [];
var temp = listOfValues.split("-");
for(var i=0; i<temp.length; i++){
temp2 = temp[i].split(',');
if(temp2.length == 7){
for(var j=0; j<temp2.length;j++){
temp3 = temp2[j].split(',');
longArray.push(temp3[0]);
}
} …Run Code Online (Sandbox Code Playgroud) 我有一个iframed到第三方网页的网站,它本身嵌入在WkWebViewiOS应用程序中.移动Safari和WkWebView拒绝为我的网站发送的会话(仅限http)cookie,基本上打破了一切.移动Safari中的解决方法是在设置中启用所有cookie(yuck)或指示用户直接访问我的站点(因此,就Safari而言,它被视为"我访问过的站点"); 这些都不是特别好吃.我没有找到解决办法WkWebView.
这个问题分为两个部分:
1)我正在考虑在我的网站中实现一个重定向服务,它将目标URL作为参数,并在页面加载时简单地将用户重定向到该URL.然后,第三方网站可以链接到我的重定向页面,其URL设置为立即向用户发送,希望这将被视为"访问"我的域,从而启用cookie.
或者,第三方站点可以打开我的站点的新选项卡,该选项卡会在加载时立即关闭.我希望这会是一种不太理想的用户体验,所以不愿意走这条路.
最重要的是"POST到隐藏的iframe"技巧(第三方页面在隐藏的iframe中POST到我的域名),但是因为SO问题表明该技巧不再有效.
这些是可行的解决方案之一,还是Apple阻止了这些设置会话cookie的方法?有没有更好的解决方案,我没有考虑过?
2)有没有办法设置cookie接受政策,WkWebViews可以这样做UiWebViews?我对StackOverflow的搜索建议没有,但我读到的答案可能基于旧版本的iOS(该应用程序需要iOS 9+).
如果没有应用程序代码解决WkWebViews方案,移动Safari的解决方案是否也适用WkWebViews?
我是谷歌排行榜的新手,所以请原谅我的无知;
我正在查看面积图,我想更改填充和描边颜色.这是代码......
<!--
You are free to copy and use this sample in accordance with the terms of the
Apache license (http://www.apache.org/licenses/LICENSE-2.0.html)
-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>
Google Visualization API Sample
</title>
<script type="text/javascript" src="//www.google.com/jsapi"></script>
<script type="text/javascript">
google.load('visualization', '1', {packages: ['corechart']});
</script>
<script type="text/javascript">
function drawVisualization() {
// Some raw data (not necessarily accurate)
var data = google.visualization.arrayToDataTable([
['Month', 'Target'],
['JAN', 85],
['FEB', 105],
['MAR', 65],
['APR', 45], …Run Code Online (Sandbox Code Playgroud) 我有一个 Powershell 脚本,它需要执行一个命令行可执行文件来提示用户输入(没有命令行参数)。像这样的东西:
# promptsForInput.ps1
$someInput = Read-Host "Gimme some input"
# do something with $someInput
Run Code Online (Sandbox Code Playgroud)
实际的可执行文件是一个编译后的二进制文件,我无法修改,但是这个示例脚本是为了这个问题。我的 Powershell 脚本调用可执行文件:
# myScript.ps1
.\promptsForInput.ps1
Run Code Online (Sandbox Code Playgroud)
在运行时,我被提示输入一些东西:
> .\myScript.ps1
Gimme some input:
Run Code Online (Sandbox Code Playgroud)
我需要能够在没有用户干预的情况下填写该输入请求。当promptsForInput.ps1提示用户输入时,我需要myScript.ps1输入所需的值并继续执行脚本。
关于 SO 的类似问题要么有特定于特定 exe 的答案,要么没有帮助:
我有一个应用FontAwesome的字形字体用于图标的应用程序,当我从我的服务器托管文件时一切正常.当我在我的网站上启用CDN支持时,IE 11在字体文件方面表现得相当奇怪.通过单击链接或手动输入URL导航到页面时,字体文件可以很好地加载~95%的时间.如果我重新加载页面或使用前进/后退按钮(或大约5%的时间正常页面加载不起作用),IE 11加载第一个字体文件,丢失/丢弃/忽略响应正文的内容,尝试加载第二个文件,丢失响应正文的内容,洗冲 - 重复,我最终没有字体字形.所有其他浏览器(包括旧版本的IE)都可以正常工作.
@font-face CSS中的声明:
@font-face {
font-family: 'FontAwesome';
src: url('/common/fonts/fontawesome-webfont.eot');
src: url('/common/fonts/fontawesome-webfont.eot?#iefix') format('embedded-opentype'),
url('/common/fonts/fontawesome-webfont.woff') format('woff'),
url('/common/fonts/fontawesome-webfont.ttf') format('truetype'),
url('/common/fonts/fontawesome-webfont.svg#fontawesomeregular') format('svg');
font-weight: normal;
font-style: normal;
}
Run Code Online (Sandbox Code Playgroud)
正常页面加载:
摘要:
URL Protocol Method Result Type Received Taken Initiator Wait Start Request Response?? Cache read?? Gap??
/common/fonts/fontawesome-webfont.eot HTTPS GET 200 application/octet-stream 99.78 KB 109 ms @font-face 2449 0 47 62 0 1420
Run Code Online (Sandbox Code Playgroud)
响应头:
Key Value
Response HTTP/1.1 200 OK
Content-Type application/octet-stream
Last-Modified Mon, 04 Aug 2014 12:49:48 GMT
Accept-Ranges bytes
ETag "07ef492e2afcf1:0" …Run Code Online (Sandbox Code Playgroud) 我正在Angular应用程序内使用Esri映射,并且将弹出式窗口渲染为Angular组件,并使用PopupTemplate的content方法发布了数据:
layer.popupTemplate = new PopupTemplate({
content: (feature: { graphic: __esri.Graphic }) => {
this.publishPopupData(layer, feature.graphic.attributes);
return popupComponent.viewContainerRef.element.nativeElement;
},
// other properties...
});
Run Code Online (Sandbox Code Playgroud)
这很好用,除非在给定点有多个要素。当用户循环浏览功能时,如果他/她返回到已经显示的功能,则不会执行content方法,因此不会发布弹出数据。
我可以在MapView的弹出窗口中访问当前选择的功能,但是我需要知道该功能来自哪一层才能正确发布数据(每一层对将ArcGIS数据处理到弹出窗口所使用的模型中都有独特的要求) 。
mapView.popup.watch('selectedFeature', (graphic: __esri.Graphic) => {
const layer = ???;
this.publishPopupData(layer, graphic.attributes);
});
Run Code Online (Sandbox Code Playgroud)
名义上,graphic.layer应该包含图层参考,但就我而言,它始终是null。
有没有一种方法可以强制弹出窗口始终调用content方法,即使该方法已经针对给定功能执行了呢?或者,是否有办法获取要素所属的图层MapView.popup(或我未考虑的其他内容)?
如果重要的话,弹出窗口用于MapImageLayer子层。
我在Spring MVC 3.1.1中继承了一个项目,我需要使用Jackson将对象序列化为JSON.我有一个对象类,如:
public class User {
Integer id;
String name;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
Run Code Online (Sandbox Code Playgroud)
和这样的控制器:
@Controller
@RequestMapping(value = "/home")
public class homeController {
@RequestMapping(value = "/")
public @ResponseBody User home() {
User user;
user = new User();
user.setId(1);
user.setName("Drew");
return user;
}
}
Run Code Online (Sandbox Code Playgroud)
导航到/ home我得到:
{"id":1,"name":"Drew"}
Run Code Online (Sandbox Code Playgroud)
太棒了,这是第一步.现在,如果我想忽略"id"参数,Jackson文档说我应该使用@JsonIgnore注释.我遇到的问题是NetBeans找不到要为Jackson导入的任何注释包,因此我无法使用注释.我尝试下载Jackson 2.2罐并将其添加到我的项目中(然后允许我导入注释),但是当我这样做时,@ JsonIgnore注释没有效果.
我怀疑我错过了来自Spring …
我觉得这里有一些非常简单的东西.我已经得到了我建立了一个使用ESRI的ArcGIS的API的一类,但是当我导入从类型定义arcgis-js-api的d.ts文件,我得到的打字稿错误"无法使用'新’与它的类型没有一个电话或一封表达构建签名."
例如:
import * as IMap from 'esri/Map';
export class Foo {
bar: (Map: IMap) {
const map = new Map(); // <-- error here
}
}
Run Code Online (Sandbox Code Playgroud)
d.ts文件中的相关摘录:
declare namespace __esri {
/* snip */
interface Map extends Accessor, LayersMixin {
allLayers: Collection;
basemap: Basemap;
ground: Ground;
}
interface MapConstructor {
new(properties?: MapProperties): Map;
}
export const Map: MapConstructor;
/* snip */
}
declare module "esri/Map" {
import Map = __esri.Map;
export = Map;
} …Run Code Online (Sandbox Code Playgroud) 我有一个查询,我需要在一个列上加入大量的表,当任何表中的任何记录与该列匹配时,应该连接记录.一个例子:
A
----------
id | a_value
----------
1 | foo
2 | bar
B
----------
id | b_value
----------
2 | cad
3 | qud
C
----------
id | c_value
----------
1 | fiz
4 | buz
D
----------
id | d_value
----------
5 | sas
6 | tos
SELECT id, a_value, b_value, c_value, d_value FROM <join A, B, C, D by id>
Run Code Online (Sandbox Code Playgroud)
应该返回如下结果集:
results
------------------------------------------
id | a_value | b_value | c_value | d_value
------------------------------------------
1 | …Run Code Online (Sandbox Code Playgroud) esri-maps ×2
typescript ×2
angular ×1
asp.net-core ×1
cdn ×1
charts ×1
esri ×1
iframe ×1
ios ×1
jackson ×1
javascript ×1
join ×1
jquery ×1
powershell ×1
spring-mvc ×1
sql ×1
wkwebview ×1