将状态映射到amp-list [src]

时间:2018-11-28 09:28:26

标签: amp-html amp-list amp-bind

我需要使用状态作为放大器清单的输入。但在此之前,我想映射状态(执行一些数学或运算)。

将数组的每个位置映射到一个对象并将其放入src时,我无法使其工作(代码here):

<amp-list [src]="menu.array.map(x => ({size_new: x.size.toUpperCase(), color_new: x.color.toUpperCase()}))" width="auto" height="100">
  <template type="amp-mustache">
    <div>
        {{size_new}} // {{color_new}}
    </div>
  </template>
</amp-list>

但是,如果我将每个数组位置映射到一个数组(代码here),则可以使它起作用:

<amp-list [src]="menu.array.map(x => [x.size.toUpperCase(), x.color.toUpperCase()])">
  <template type="amp-mustache" width="auto" height="100">
    <div>
        {{0}} //  @RequiresApi(api = Build.VERSION_CODES.M)
    private void createKey() {
        try {
            KeyStore keyStore = KeyStore.getInstance("AndroidKeyStore");
            keyStore.load(null);
            KeyGenerator keyGenerator = KeyGenerator.getInstance(
                    KeyProperties.KEY_ALGORITHM_AES, "AndroidKeyStore");
            keyGenerator.init(new KeyGenParameterSpec.Builder(KEY_NAME,
                    KeyProperties.PURPOSE_ENCRYPT | KeyProperties.PURPOSE_DECRYPT)
                    .setBlockModes(KeyProperties.BLOCK_MODE_CBC)
                    .setUserAuthenticationRequired(true)
                    // Require that the user has unlocked in the last 30 seconds
                    .setUserAuthenticationValidityDurationSeconds(AUTHENTICATION_DURATION_SECONDS)
                    .setEncryptionPaddings(KeyProperties.ENCRYPTION_PADDING_PKCS7)
                    .build());
            keyGenerator.generateKey();
        } catch (NoSuchAlgorithmException | NoSuchProviderException
                | InvalidAlgorithmParameterException | KeyStoreException
                | CertificateException | IOException e) {
            throw new RuntimeException("Failed to create a symmetric key", e);
        }
    }

    </div>
  </template>
</amp-list>

有什么建议吗?谢谢!

1 个答案:

答案 0 :(得分:0)

此问题最近已通过https://github.com/ampproject/amphtml/pull/23762

解决。