我试图在通过 NgRx 功能模块组合状态时注入功能减少器。
import { NgModule, InjectionToken } from '@angular/core';
import { StoreModule, ActionReducerMap } from '@ngrx/store';
import * as fromFeature from './reducers';
export const FEATURE_REDUCER_TOKEN = new InjectionToken<ActionReducerMap<fromFeature.State>>('Feature Reducers');
Run Code Online (Sandbox Code Playgroud)
我应该在这里返回什么?
export function getReducers(): ActionReducerMap<fromFeature.State> {
// map of reducers
return {
};
}
Run Code Online (Sandbox Code Playgroud)
我试过
export function getReducers(): ActionReducerMap<fromFeature.State> {
// map of reducers
return {
reducerA: FeatureAReducer
};
}
Run Code Online (Sandbox Code Playgroud)
但它给出了错误Object literal may only specified known properties。
其余模块代码:
@NgModule({
imports: [
StoreModule.forFeature('feature', FEATURE_REDUCER_TOKEN),
],
providers: [ …
Run Code Online (Sandbox Code Playgroud) 我想绕过通过反向代理的同源策略,iframe
以便对iframe
.
src
iframe 的设置为https://example1.com/iframe-app
. 但这仍然会在浏览器中引发同源策略违规。所以浏览器仍然会看到 iframe 中的页面,因为它不是源自https://example1.com/
,这似乎没问题,因为如果底层页面具有相同的来源,那么它的 ajax 请求将不起作用。
所以我尝试使用 nginxsub_filter
指令将我的 javascript 注入响应 html。但是,没有在响应中添加任何内容。也许这是因为响应是由于 https 协议而加密的?
为什么sub_filter
不起作用以及如何使其工作?
server {
root /var/www/example1.com/html;
index index.html index.htm index.nginx-debian.html;
server_name example1.com www.example1.com;
location / {
proxy_pass http://localhost:4000;
}
location /iframe-app {
rewrite ^/iframe-app(.*) /$1 break;
proxy_pass http://example2.com;
proxy_set_header Accept-Encoding "";
proxy_redirect off;
sub_filter '</head>' '<script>...code</script></head>';
sub_filter_once on;
sub_filter_types text/html;
}
listen [::]:443 ssl ipv6only=on; …
Run Code Online (Sandbox Code Playgroud) 我的 ASP.NET Core Web API 应用程序的控制器中有两个操作:
[HttpGet("get-all")]
public IActionResult GetAll() { ... }
Run Code Online (Sandbox Code Playgroud)
和
[HttpDelete("{id}")]
public IActionResult Delete(int id)
{
...
return RedirectToAction("GetAll");
}
Run Code Online (Sandbox Code Playgroud)
Delete
动作总是重定向到它自己,而不是重定向到GetAll
。为什么这样?同时,类似的来自Post
操作的重定向也可以正常工作。
找不到有关该主题的任何文档。有什么帮助吗?
我正在阅读ngrx文档并偶然发现了这样的代码。什么[p in keyof T]
和T[p]
意味着什么呢?
export type ActionReducerMap<T, V extends Action = Action> = {
[p in keyof T]: ActionReducer<T[p], V>
};
Run Code Online (Sandbox Code Playgroud) Angular 会忽略script
其模板中的标签,但需要它们来加载 GitHub gist。执行此操作的最佳做法是什么?使用iframe
?script
动态创建标签?或者是其他东西?
我在我的网站上使用 QuillJs 作为文本编辑器。在长帖子中,当粘贴文本或更改标题类型或对齐方式或颜色或插入链接或视频时,屏幕视图会跳到顶部。无法找出原因。
QuillJs 版本:1.2.6 浏览器:Chrome 58.0.3029.110 操作系统:Windows 10
初始化:
var toolbarOptions = [
[{ 'header': [1, 2, 3, 4, 5, 6, false] },
'bold', 'italic', 'underline', 'strike', { 'align': [] },
{ 'list': 'ordered' }, { 'list': 'bullet' },
{ 'color': [] }, { 'background': [] }],
['image', 'blockquote', 'code-block', 'link', 'video'],
['clean']
];
var quill = new Quill('#editor', {
modules: {
toolbar: toolbarOptions
},
theme: 'snow'
});
Run Code Online (Sandbox Code Playgroud)
或者,也许您可以为网站推荐一个更好的简单且免费的 html 编辑器?我不喜欢 CKE 或 Tinymce。
我有一段简单的代码无法工作:
<div class="cover"
[style.background-image]="sanitizer.bypassSecurityTrustStyle('url(/assets/img/picture (1).jpg)')">
</div>
Run Code Online (Sandbox Code Playgroud)
返回sanitizer.bypassSecurityTrustStyle
以下消息:
SafeValue must use [property]=binding: url(/assets/img/picture (1).jpg) (see http://g.co/ng/security#xss)
Run Code Online (Sandbox Code Playgroud)
还尝试将消毒转移到自定义管道,结果是相同的。
当尝试以下解决方案时,Angularstyle.background-image
完全忽略:
[style.background-image]="'url(' + photo + ')'"
[ngStyle]="{'background-image': 'url(' + photo + ')'}"
为什么?
角度:5.2.4
javascript ×3
angular ×2
ngrx ×2
asp.net-core ×1
embedding ×1
gist ×1
github ×1
iframe ×1
nginx ×1
ngrx-store ×1
quill ×1
sanitization ×1
typescript ×1