Angularjs 聚合物相当于ng秀?

Angularjs 聚合物相当于ng秀?,angularjs,polymer,polymer-1.0,Angularjs,Polymer,Polymer 1.0,对于ng show,a聚合物是否等效?下面是我试图转换的代码片段示例: <h1>Greeting</h1> <div ng-show="authenticated"> <p>The ID is {{controller.greeting.id}}</p> <p>The content is {{controller.greeting.content}}</p> </div> <d

对于
ng show
,a聚合物是否等效?下面是我试图转换的代码片段示例:

<h1>Greeting</h1>
<div ng-show="authenticated">
    <p>The ID is {{controller.greeting.id}}</p>
    <p>The content is {{controller.greeting.content}}</p>
</div>
<div  ng-show="!authenticated">
    <p>Login to see your greeting</p>
</div>
问候语
ID为{{controller.greeting.ID}

内容为{{controller.greeting.content}

登录以查看您的问候语

我想您可以使用它在DOM树中有条件地保留所需的HTML<代码>属性应在组件的
属性
中定义

<template is="dom-if" if="{{authenticated}}">
   <p>The ID is {{controller.greeting.id}}</p>
   <p>The content is {{controller.greeting.content}}</p>
</template>
<template is="dom-if" if="{{!authenticated}}">
   <p>Login to see your greeting</p>
</template>

ID为{{controller.greeting.ID}

内容为{{controller.greeting.content}

登录以查看您的问候语


dom,如果此处不需要
。只需使用
$=
(属性绑定)添加/删除
隐藏的属性

<style>
[hidden] {
    display:none;
}
</style>

<h1>Greeting</h1>
<div hidden$=[[!authenticated]]>
    <p>The ID is {{controller.greeting.id}}</p>
    <p>The content is {{controller.greeting.content}}</p>
</div>
<div hidden$=[[authenticated]]>
    <p>Login to see your greeting</p>
</div>

[隐藏]{
显示:无;
}
招呼
ID为{{controller.greeting.ID}

内容为{{controller.greeting.content}

登录以查看您的问候语


使用
dom if
来决定不希望呈现的代码块,而不仅仅是隐藏的代码块。

在模板中添加模板后,True和False将起作用。我试过了

   <template>
    <template is="dom-if" if="{{authenticated}}">
        {{authenticated}}
        <p>The ID is {{controller.greeting.id}}</p>
        <p>The content is {{controller.greeting.content}}</p>
     </template>

    <template is="dom-if" if="{{!authenticated}}">
        {{authenticated}}
        <p>Login to see your greeting</p>
     </template>
    </template>

{{authenticated}}
ID为{{controller.greeting.ID}

内容为{{controller.greeting.content}

{{authenticated}} 登录以查看您的问候语

如果您不在模板中添加带“真”的模板,则“假”将永远不起作用。无论属性值是真是假,它都会显示第一个模板


希望它能工作。

dom if等同于ng if!即使我返回真和假,但每次它都显示第一个模板。authenticated的天气值为true或false@Rahul你能检查一下你正在检索的
authenticated
值是否为
Boolean
格式,因为
'true'
/
'false'
将始终返回truthyauthenticated:{type:Boolean,value:false,notify:true},是的,检查我的property@Rahul所以你应该说on
{{authenticated.value}}