我有一个Angular 1.x应用程序,我试图在Polymer 1.0的帮助下更新到材料设计.我必须声明我只使用纸质元素作为普通构建块,并且我没有编写任何自定义聚合物代码.
到目前为止,我遇到了两个问题,都处理嵌套的Polymer元素,所以我猜解决方案将是相同的或至少非常相似.
问题1
ng-repeat在纸上使用.
HTML代码(使用Angular模板语法)
<paper-item data-ng-repeat="event in events">
<paper-item-body two-line>
<div>{{event.title}}</div>
<div secondary>{{event.description}}</div>
</paper-item-body>
</paper-item>
Run Code Online (Sandbox Code Playgroud)
以下代码不会运行,因为它会产生以下错误:
TypeError: Cannot read property 'childNodes' of undefined
at g (angular.js:7531)
at g (angular.js:7531)
at N (angular.js:8127)
at g (angular.js:7527)
at angular.js:7402
at $get.h (angular.js:7546)
at m (angular.js:8159)
at angular.js:27052
at Object.fn (angular.js:15474)
at m.$get.m.$digest (angular.js:15609)
Run Code Online (Sandbox Code Playgroud)
但是,如果我使用以下代码,代码确实运行没有错误:
<div data-ng-repeat="event in events">
<paper-item-body two-line>
<div>{{event.title}}</div>
<div secondary>{{event.description}}</div>
</paper-item-body>
</div>
Run Code Online (Sandbox Code Playgroud)
注意,我只改变的根元素(从paper-item至div).
问题2
尝试使用google-map在 …
ElasticSearch 5.x对Suggester API(文档)引入了一些(重大)更改.最值得注意的变化如下:
完成建议是面向文档的
建议知道他们所属的文件.现在,关联的文档(
_source)将作为完成建议的一部分返回.
简而言之,所有完成查询都返回所有匹配的文档而不是匹配的单词.这就是问题所在 - 如果自动填充的单词出现在多个文档中,则会重复这些单词.
假设我们有这个简单的映射:
{
"my-index": {
"mappings": {
"users": {
"properties": {
"firstName": {
"type": "text"
},
"lastName": {
"type": "text"
},
"suggest": {
"type": "completion",
"analyzer": "simple"
}
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
有一些测试文件:
{
"_index": "my-index",
"_type": "users",
"_id": "1",
"_source": {
"firstName": "John",
"lastName": "Doe",
"suggest": [
{
"input": [
"John",
"Doe"
]
}
]
}
},
{
"_index": "my-index",
"_type": "users",
"_id": …Run Code Online (Sandbox Code Playgroud) 我用Polymer创建了一个自定义Web组件,它包装文本并稍微改变它(在这个概念证明中转换为大写).
元素本身可以与静态内容一起使用.但是,当内容动态绑定时,组件无法显示内容.
例如:
<my-wrapper>Hello, World!</my-wrapper> <!-- Works -->
<my-wrapper>[[someText]]</my-wrapper> <!-- Doesn't work -->
Run Code Online (Sandbox Code Playgroud)
目前我正在使用observeNodes,它设法触发初始文本转换,但无法触发子顺序更改.
我目前的原型定义为:
<dom-module id="my-wrapper">
<template>
<span id="placeholder"></span>
</template>
<script>
Polymer({
is: 'my-wrapper',
ready: function() {
var self = this;
Polymer.dom(Polymer.dom(this)).observeNodes(function(info) {
self.$.placeholder.textContent = info.target.textContent.toUpperCase();
});
/*var mutationObserver = new MutationObserver(function(e) {
console.log(e);
});
mutationObserver.observe(this.root, {characterData: true, childList: true});*/
},
});
</script>
</dom-module>
Run Code Online (Sandbox Code Playgroud)
可以在这里找到针对上述问题的工作JSBin:http://jsbin.com/jumewuzuho/1/edit?html,console,output.
关于如何捕获(轻DOM)内容的变化的任何建议,以便我可以重新转换文本?
正如你在注释的代码块中看到的那样,我已经尝试过使用MutationObserver,但是无法创建一个工作原型.我的猜测是我没有使用正确的节点(this.root在我的情况下).
我正在使用Cookie中间件来验证用户身份.我一直在关注这个官方教程.
在我的Startup课程中,我的Configure方法摘录如下:
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
// ...
// Cookie-based Authentication
app.UseCookieAuthentication(new CookieAuthenticationOptions()
{
AuthenticationScheme = CookieAuthenticationDefaults.AuthenticationScheme,
AutomaticAuthenticate = true,
AutomaticChallenge = true,
Events = new CustomCookieAuthenticationEvents(app),
});
// ...
}
Run Code Online (Sandbox Code Playgroud)
所述CustomCookieAuthenticationEvents类的定义如下:
public class CustomCookieAuthenticationEvents : CookieAuthenticationEvents
{
private IApplicationBuilder _app;
private IMyService _myService = null;
private IMyService MyService
{
get
{
if(_myService != null)
{
return _myService;
} else
{
return _myService = (IMyService) _app.ApplicationServices.GetService(typeof(IMyService));
} …Run Code Online (Sandbox Code Playgroud) asp.net configuration dependency-injection startup asp.net-core
我有一个Polymer 1.0项目,我想要进行硫化生产.我使用Gulp gulp-vulcanize来做到这一点.
我的gulpfile.js档案:
var gulp = require('gulp');
var Vulcanize = require('gulp-vulcanize');
gulp.task('vulcanize', function () {
return gulp.src('./src/app.html')
.pipe(Vulcanize({
inlineCss: true
}))
.pipe(gulp.dest('./dist'));
});
Run Code Online (Sandbox Code Playgroud)
内容src/app.html如下:
<!-- Polymer elements -->
<link rel="import" href="../bower_components/google-map/google-map.html" />
<link rel="import" href="../bower_components/iron-icons/iron-icons.html" />
<link rel="import" href="../bower_components/paper-button/paper-button.html" />
<link rel="import" href="../bower_components/paper-drawer-panel/paper-drawer-panel.html" />
<link rel="import" href="../bower_components/paper-icon-button/paper-icon-button.html" />
<link rel="import" href="../bower_components/paper-item/paper-item.html" />
<link rel="import" href="../bower_components/paper-material/paper-material.html" />
<link rel="import" href="../bower_components/paper-menu/paper-menu.html" />
<link rel="import" href="../bower_components/paper-progress/paper-progress.html" />
<link rel="import" href="../bower_components/paper-scroll-header-panel/paper-scroll-header-panel.html" />
<link rel="import" href="../bower_components/paper-toast/paper-toast.html" />
<link rel="import" …Run Code Online (Sandbox Code Playgroud) 我想触发股票ScriptTagHelper(在 GitHub 上查看源代码),以便它模拟该asp-append-version="true"属性。
我知道使用它的正确方法是改变这个:
<script src="somefile.js"></script>
Run Code Online (Sandbox Code Playgroud)
对此:
<script src="somefile.js" asp-append-version="true"></script>
Run Code Online (Sandbox Code Playgroud)
这个过程与版本控制 CSS 包含和图像(LinkTagHelper和ImageTagHelper)非常相似。
由于我有很多包含的脚本、样式表和图像,我想自动化一些事情。因此asp-append-version="true",与其添加每个 HTML 元素,不如创建一个自定义 TagHelper 来为我执行此操作。
这就是问题所在 - 它不起作用。
目前,我的 TagHelper 仅涵盖script标签,如下所示:
[HtmlTargetElement("script", Attributes = "src")]
public class TestTagHelper : TagHelper
{
public override int Order => int.MinValue;
public override void Process(TagHelperContext context, TagHelperOutput output)
{
if(!context.AllAttributes.ContainsName("asp-append-version"))
{
output.Attributes.SetAttribute("asp-append-version", "true");
}
}
}
Run Code Online (Sandbox Code Playgroud)
但它不会触发默认值ScriptTagHelper,而是直接将 输出
asp-append-version="true"到输出 HTML。我还将该Order属性设置为 INT_MIN,以便它在任何其他标签助手之前触发,但它仍然不起作用。
有没有办法使这项工作?
c# asp.net-core-mvc tag-helpers asp.net-core asp.net-core-2.0
polymer-1.0 ×3
asp.net-core ×2
javascript ×2
polymer ×2
angularjs ×1
asp.net ×1
autocomplete ×1
c# ×1
data-binding ×1
duplicates ×1
gulp ×1
startup ×1
tag-helpers ×1