Polymer Dart是否有类似于Angular的ng-switch的东西?



聚合物中是否有某些东西可以在标记中执行switch语句?我有这个想要构建的组件,它可以有大量的"IF"来简单地显示一些代码。我想知道聚合物是否有类似 Angular 的ng-switch

例:

<div ng-switch="selection">
  <div ng-switch-when="settings">Settings Div</div>
  <div ng-switch-when="home">Home Span</div>
  <div ng-switch-default>default</div>
</div>

在聚合物中,你只有'

<template if="{{selection == 'settings'}}">....</template>
<template if="{{selection == 'home'}}">....</template>
<template if="{{!(selection == 'settings' && selection == 'home')}}">....</template>

这显然不像ng-switch那么简洁.

在聚合物中,0.8 <template if...><template repeat...>是作为自定义元素构建的。对于开关也可以这样做。

最新更新