Aurelia选择不起作用 [英] Aurelia select doesn't work

查看:110
本文介绍了Aurelia选择不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下问题. 我正在尝试通过读取json文件来填充一个简单的选择,而不是在选择内将任何对象的标题显示为选项. 当我尝试在div元素中显示标题时,代码工作得很好,但在select中却不行. 这是我的代码:

I have the following problem. I'm trying to fill a simple select by reading a json file and than displaying the title of any object as an option inside the select. The code works just fine when i try to display the titles inside div elements, but not as select. Here is my code:

import {inject} from 'aurelia-framework';
import {HttpClient} from 'aurelia-http-client';

@inject(HttpClient)
export class Select{
title = "Title";
images = [];
url = 'http://api.flickr.com/services/feeds/photos_public.gne?tags=rainier&tagmode=any&format=json';
favImage = '';

constructor(http) {
    this.http = http;
}

activate() {
    return this.http.jsonp(this.url).then(response => {
        this.images = response.content.items;
    });

}

}

和HTML

<template>
<div>${title}</div> 
<div repeat.for="pic of images">${pic.title}</div> //This works just fine
<select value.bind="favImage"> //This doesn't work
    <option>Select Picture</option>
    <option repeat.for="pic of images" model.bind="pic">${pic.title}</option>
</select>

推荐答案

尝试安装最新的skelly https://github.com/aurelia/skeleton-navigation/releases ,即0.13.0.编写相同的代码,它应该可以工作.

Try installing latest skelly https://github.com/aurelia/skeleton-navigation/releases which is 0.13.0. Write same code and it should work.

请确保从js文件导出的模型(视图模型)的名称与模板(html)文件的名称相符.

Make sure that the name of the model (viewmodel) which you export from your js file matches the name of the template (html) file.

这篇关于Aurelia选择不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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