聚合物Web组件的属性值没有得到传承下来 [英] Polymer web component attribute value not getting passed down

查看:140
本文介绍了聚合物Web组件的属性值没有得到传承下来的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在的 WebComponents 库.COM /相对=nofollow> Github上,而这一切通过它的工作原理以及测试时的自我。

I have started out my own little WebComponents library at Github, and it all works well by it self when tested.

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>WebComponents</title>
    <script src="bower_components/platform/platform.js"></script>
    <link rel="import" href="bower_components/polymer/polymer.html">
    <link rel="import" href="bower_components/WebComponents/components/scheduler/ss-scheduler.html">
</head>
<body>
    <ss-scheduler cronValue="0 0 0 0 *"></ss-scheduler>
</body>
</html>

这会使这样的组件

这个片段展示了如何使用 Web组件的使用,应和的 cronValue 是正确拿起和的 Web组件的内部使用。
然而,当我尝试使用的 Web组件的另一个项目我有 Github上,只有被传递到的 Web组件

This snippet shows how the web component should be used, and the cronValue is correctly picked up and used inside the web component. However when I try to use the web component in another project I have on Github, only null is passed down to the web component.

websync 客户端使用的 angularjs与聚合物 Web组件一起的。

websync client side uses angularjs together with Polymer web components.

<ss-scheduler cronValue="{{task.schedule.time}}" ng-class="{hidden: !task.schedule.enabled}"></ss-scheduler>

在这里,我想绑定的角范围的值到的 cronValue 属性,但里面的日志语句的 Web组件的说明,没有什么是已接。
我在我的指令的揭 task.schedule.time 价值,它不是空<添加日志声明/ code>。

Here I am trying to bind a angular scope value to the cronValue attribute, but a log statement inside the web component shows that nothing is picked up. I have added a log statement in my directive exposing the task.schedule.time value, and it is not null.

介于两者之间的值不正确绑定到的 Web组件的通过的

Somewhere in between the value is not correctly bound to the web component by angular.

我发现这个项目,同时研究并努力解决此事,角结合聚合物
但是,这不仅有助于值内做出改变的 Web组件的被角,这也不会做即使有这种被拾起的指令

I found this project while researching and trying to resolve the matter, angular-bind-polymer. But that only helps changes made to the value inside the web component to be picked up by angular, which it also doesn't do even with this directive.

现在我转交给你(计算器),在计算出的希望,为什么的斜网组件绑定的是行不通的。

I now turn to you (StackOverflow), in hopes of figuring out why the angular web component binding isn't working.

编辑:

我现在也尝试过安固聚以及它也不能正常工作。

I have now also tried angu-poly and it's also not working.

推荐答案

好像从 cronValue 更改属性名称 cronvalue 解决了这个问题,现在角结合聚合物安固聚作品就好。

Seems like changing the attribute name from cronValue to cronvalue solved the issue, now angular-bind-polymer and angu-poly works just fine.

聚合物的文档,它说:

In the Polymer documentation it says:

值得注意的是,HTML解析器认为属性名的情况下
  不敏感的。然而,在JavaScript属性的名称是区分大小写的。

It’s worth noting that the HTML parser considers attribute names case insensitive. Property names in JavaScript are however case sensitive.

这意味着,属性可以写你喜欢的任何方式,但
  如果你看一下元素的属性列表,这些名称将永远是
  小写。聚合物是意识到了这一点,并会尝试匹配
  属性仔细属性。例如,这应该工作
  预计:

This means that attributes can be written any way that you like, but if you look at an element’s attribute list, the names will always be lowercase. Polymer is aware of this and will attempt to match the attributes to properties carefully. For example, this should work as expected:

这可能是如此的聚合物的,但加上的 angular.js 的两种方式的结合似乎崩溃和不`吨的工作。

This is probably true for Polymer but together with angular.js the two way binding seems to fall apart and don`t work.

这篇关于聚合物Web组件的属性值没有得到传承下来的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆